Separation of concerns: Does a single XML document define structure, content, and presentation/format all in one place by default?
-
AIncorrect: XML carries content and structure, not presentation
-
BCorrect: XML always embeds formatting with data
-
CCorrect only when using inline CSS
-
DCorrect only with XSL-FO
Answer
Correct Answer: Incorrect: XML carries content and structure, not presentation
Explanation
Introduction / Context:XML was designed to separate content/structure from presentation. While XML documents express data and hierarchy via elements and attributes, visual formatting is typically handled externally (e.g., CSS, XSLT, XSL-FO). This question probes that separation-of-concerns principle.
Given Data / Assumptions:
- We discuss plain XML, not HTML with inline styles.
- Formatting/presentation is distinct from semantic structure.
- XML may be transformed into presentational forms (HTML, PDF) via XSLT or XSL-FO.
Concept / Approach:By default, an XML document stores structured data (elements/attributes) and content (text nodes). It does not prescribe how that data should look when rendered. Presentation requires separate technologies: CSS can style XML in some user agents; XSLT maps XML to presentational HTML; XSL-FO defines layout for paginated output (e.g., PDF). Therefore, the statement that XML bundles structure, content, and format “within one document” is inaccurate as a general rule.
Step-by-Step Solution:
Identify what XML provides: tags convey semantics and hierarchy.Identify what presentation requires: stylesheets or transformations.Conclude that XML alone does not define presentation/format.Verification / Alternative check:Open an XML document in a browser without stylesheets: it shows a generic tree view or plain text; presentation depends on added CSS or transformed HTML, not the XML itself.
Why Other Options Are Wrong:
- “XML always embeds formatting” conflates XML with HTML or with styled outputs.
- “Inline CSS” or “XSL-FO” are optional techniques external to the raw XML data.
Common Pitfalls:Embedding presentational hints in element names (e.g.,
Final Answer:Incorrect: XML carries content and structure, not presentation