XML Flashcards
XML is extensible (not fixed) but which markup is indifferent across all XML languages and how is it written?
Metadata
Database vs XML
data centric means it is largely intended for auto processing, has to be easily identifiable & have regular structure should be database
document centric means it should be more human readable with maybe a little less structure. This should be xml
XML is self describing [structure of the document is within the document itself
Although XML parsing & processing can be slow. Also missing key db features (index, security, queries etc)
XML is an ordered, labelled tree. Name & describe its nodes
Character data: leaf node contain actual data (text strings)
Element Nodes: labellled with a tag and a set of attributes.
Other Leaf nodes:
- Attribute Nodes
- Processing instructions - annotations for vatious processors
- Comments
- Document Type Declaration
Basic XML Syntax Rules
- Must have unique root element
- Element names are any length and are aplhanumeric with underscores, hyphens and period. Must begin with alpha or underschore. No spaces!
- Element names are case SeNsItIvE
- Every tag should have an open and close (in that order).
- Child closed before folks
What is Character Data?
String Data which supports:
- Carraige Returns
- Line Feeds
- Unicode Characters
Whitespace is preserved by XML parsers!
Reserved chars: & | < | > | ‘ | “
What are entity references?
Allows you to include reserved characters in your XML data [&entity-name]
& = &
< = <
> = >
' = ‘
" = “
True or False?
Attributes only describe one element?
False
Attributes descibe element and it’s children.
What are processing instructions?
Give an example.
Processing data is metadata about the XML document intended for processing tools.
Typical examples are declaring which version of XML you are using & declareing which stylesheet should be applied.
Belongs as the first line all you xml documents
<?xml version=”1.0”?>
What would be the best way to include Code in your xml?
Using cdata sections
To avoid using entity references. CData will designate portions of the XML document to be skipped over by the parser and treat as pure string of character data.
The only text that isn’t excluded is ]] as it’s CDATA closing tags
Why are namespaces used?
Give an example.
XML Namespaces provide a method to avoid element name conflicts and are defined by the developer.
They allow metadata tags to be created uniquely with respect to all other Markup language by using xmlns:namespace = “AnyUniqueString”
Tip: URL’s are a good way to ensure uniqueness “http://melenie.co.uk/library/book/hello”
[But it’s not 100%]
Can the default namespace be used in conjunction with named namespaces?
Yes!
This will identify a unique namespace with the unique string used and any tags used in the document will associated with that unique namespace
In what way can semantic (meaningful) content be added to xml?
CSS
How can you define an XML Language
Using DTD or Schemas