Xml 2022 Study Guide With Complete Solutions
XML Extensible Markup Language Used to structure and describe information - Tag-based syntax like HTML - You can make up your own tags What is XML used for? - Intended for the Internet - A way to interchange data between disparate systems - Foundation for XTHML, RSS, AJAX - Does not replace HTML; more of a way to create tag sets like HTML for specific purposes XPath Extensible Path Language - Used to extract data from inside an XML file - Uses a path-like syntax XQuery Used to perform query functions on XML data, similar to SQL for databases XPointer and XLink Used to create hyperlinks to XML documents and arbitrary points within XML documents XSLT Extensible Stylesheet Language Transformations Styling language that takes an XML file and "transforms" it into something else, like HTML, PDF, ASCII, or even another XML file XML isn't good at... - Handling large amounts of data - Difficult to read if a file has a large amount of information - Images and binary data not well represented - Simplicity makes it easy to get in over your head XML Syntax Rules - All XML documents have a single root tag (like the HTML tag) - XML documents must be well-formed: --close empty tags with /, instead of doing elem/elem --Attributes cannot be minimized (element attr is wrong, must be element attr="" --Attribute values must always be inside quotes (ex: element attr="attr") --Tags must be properly nested inside of each other XML Declaration ? xml version="1.0" encoding="utf-8" standalone="yes"? - Must be at the very start of the document, no white space - Assumes encoding is UTF-8 if you don't set it otherwise - Standalone declaration states whether the documents stands by itself, or references other markup Tag naming conventions - Must begin with underscore or letter, followed by letters, digits, periods, hyphens, or underscores - Can't use "xml" in the name at all Valid names: _Element1 My.Element Invalid: 1Tag Attribute naming conventions - Specified at the start tag of an element - Must begin with underscore or letter, followed by letters, digits, periods, hyphens, or underscores - Can't use "xml" in the name at all - Attributes can only appear one time per element (invalid ex: element attr="1" attr="2" Comments !-- XML Comment -- - Can contain any characters except a double hyphen (&, , etc. are allowed) - Can appear anywhere except inside of an element, and not before the XML declaraction Character Data Sections Used to contain character data that you don't want to be parsed ![CDATA[some text data]] - Aka CDATA sections - Typically used when the character data contains a lot of characters like & or that would be illegal in XML markup - Cannot nest--no CDATA section inside of another Processing Instructions Special instructions that are only of interest to the application processing the XML ? target instruction ? - "xml" cannot be used - Target names begin with underscore or letter, followed by letters, digits, periods, hyphens, or underscores Ex: your application has different spell checking modes, and you want to specify the mode in the document: ?SpellCheckMode mode="us-english"? Entities Provide a way to shorten and modularize your XML documents - Provide a way to include characters that would otherwise be illegal in the markup - General Entities: --defined to be whatever you want, and it will be replaced by the parser with a full string --©right; = copyright symbol - Character Entities: -- Ampersand and # symbol --Reserved names: & (ampersand) " (quote) What is a valid XML document? One that has been tested against a set of rules. Specified as XML schema or DTD (Document Type Definition); DTD is simple but less powerful & uses different syntax from XML XML Namespaces Provide a way for preventing tags with same names & different meanings from conflicting. Has the form: html xmlns = "" Doesn't actually use the URLs You must declare a namespace with a prefix; the XML namespace without colons and a prefix is the default namespace (in the case below, HTML): table xmlns="" xmlns:furn=" trtdfurn:table sku="12312"Table/td/tr trtdfurn:typeCoffee Table/td/tr Whitespace handling XML parser ignores white space unless it occurs inside an element. Whitespace includes carriage returns, spaces, tabs, new lines, etc. xml:space helps you control what happens when the XML parser tries to guess what the whitespace means in an element: - "default": use default settings - "preserve": preserve all white space - Browser determines how to interpret the whitespace - Data binding will ensure that a browser (like IE) preserves the whitespace as-is
Document information
- Uploaded on
- October 1, 2022
- Number of pages
- 4
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers