3/6 - XML Flashcards

1
Q

What does XML stand for?

A

eXtensible Markup Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does XML do?

A
  • Use to add lightweight semantic info (what the code means) to plain text
  • It can describe complex structured data
  • It is not a programming language, it’s just data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does DTD stand for?

A

Document Type Definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is DTD?

A
  • Just a general structure for a family of XML documents
  • We can have one DTD (specifies the grammar/syntax) and have many XML document that obey that DTD
  • This is similar to having one HTML syntax and many HTML pages that obey that syntax
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

XPath

A
  • Compact syntax for grabbing fragments of XML data
  • Vaguely similar to regular expressions
  • It is a way of picking out a piece of an XML document
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does XSLT stand for?

A

eXtensible Stylesheet Language Transformation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is XSLT?

A
  • It is similar to a programming language, since it has conditionals, loops etc
  • It is a language for transforming XML
  • Uses XPath
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Markup Languages?

A
  • Markup languages give structure and meaning to plain text
  • The idea behind markup languages is to add some semantic info (meaning or structure) to plain text
  • They are like a lightweight overlay on top of your plain text
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Creating Your Own Markup Language

A
  • HTML is one of the markup language. It is used for describing web pages
  • If web pages are not the things you are interested in, then you can make your own markup vocabulary.
  • XML provides a generic syntax for defining your own custom markup language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

XML start and end tags

A

angle brackets (e.g. basil )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

XML how to delimit elements

A
  • Tags delimit elements.

* The whole thing from the start tag (<>) to the end tag (>) defines an element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where are XML attributes placed, and are they required?

A

Start tags have attributes which are optional. Duplicate attribute name is not allowed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

XML shorter syntax for empty elements

A

e.g.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

XML element and attribute name

A

We can make up any element and attribute name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to use XML special characters?

A

Special characters cannot be used in XML unless you escape them
• “” has to be used as &gt
• “&” has to be used as &amp
• Characters not in ASCII have to be used by their Unicode representation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Nesting XML elements

A

Elements must be strictly nested and explicitly closed

Think of elements as nested matching parentheses.

17
Q

root element

A

the top level element (there is exactly ONE)

18
Q

XML docs as trees

A

Every well-formed XML document is a tree

Strict nesting determines parent child relationship

19
Q

What are the nodes in the tree?

A

Elements are nodes

• May have zero or more ordered children

20
Q

What are the leaf nodes?

A

Runs of original text become leaf nodes (they cannot have any children)

21
Q

What purpose do attributes serve, in the context of a tree?

A

Attributes are extra info on elements

• Collection of key value pairs like {name: value}

22
Q

Are attributes ordered?

A

Attributes are unordered unlike child nodes

23
Q

Extra parsing of attribute values

A

No extra parsing or interpretation of attribute values

24
Q

Well Formed XML

A

Requires only proper syntax, nesting, entity escaping
• Sufficient to ensure that one can construct an unambiguous tree
• Every XML parser will interpret your XML in the same way
• XML is used to exchange data between different computers, so every parser must have a consistent interpretation.
• If XML is not well formed then it is not XML

25
Q

Validated XML

A
  • Must be at least well-formed XML
  • Document tree obeys extra rules about, what appears where
  • Rules provided by designer of markup vocabulary
26
Q

DTD: Document Type Definition

A
  • Gives the general format of a family of XML documents
    • Gives a set of rules that describe what is allowed where
  • If an XML doc is not well formed parser cannot even try to validate it.
  • Many parsers offer both validating and non validating modes
27
Q

Validating vs Non-Validating XML parser

A
  • A validating XML parser first constructs the tree to make sure your document is well formed and then it checks it against the DTD.
  • A non-validating parser only checks for well formed XML
28
Q

DTD Element Properties

A
  1. Ordering
  2. Repetition
  3. Special kinds of content
29
Q

Ordering

A
  • Ordering of child nodes, if any are allowed
  • Specific order: foo, bar, baz
  • Mixed in any order: foo, bar, baz
30
Q

Repetition

A

?: Zero or one repetition. Means that it is optional. Example: foo?

: Zero or more repetition. Example: bar

+: One or more repetition. Example: baz+

31
Q

Special kinds of content

A
  • EMPTY. Element must have nothing. It is not even allowed to be wrapped around text
  • # PCDATA : Just means plain text. Stands for Parsed Character DATA. Not allowed to have any elements in it. So if you have any > or < you must escape them using &
32
Q

Example: General Shakespearean Play in DTD

A

: title is just wrapped around parsed character

33
Q

Disclaimer about DTD and XML

A

A DTD itself is NOT an XML document. They are defined by SGML.

DTDs use < or >. They are not XML. DTD describes the grammar of XML doc

34
Q

DTD Attribute Properties

A

Each element has a list of allowed attributes

Each attribute has a NAME, TYPE and DEFAULT VALUE