XML & XML Query Flashcards
XML attribute vs subelement
Attribute-provides extra information about the element ex: [stuff]
Attributes are better for metadata about the element
sub-element ex: A-101
data about the element itself should be stored as subelements
When to attribute or subelement?
use attributes for identifiers
use sub-elements for contents of the element
What is the motivation for a xmlns?
the organization or context for which a given user-defined tag is from helps to determine its meaning.
Since tags are user-defined, different organizations may have tags of the same name with different meanings
The name of an organization is typically expressed with a unique URI (ex: http://www.FirstBank.com)
To avoid ambiguity each tag element could be specified by the following syntax: “”
Writing the unique URI along with every element on the page would quickly become tedious since they can get very long
What is an XMLNS and what is the syntax?
an xmlns is a shortened name that represents the unique URI for an organization
ex: xmlns:FB=”http://www.FirstBank.com” Now every tag element in the belonging to this organization (or in the FB namespace) can be referenced as
(Be sure to remember the colon between the name of the namespace and the tag_name)
4 characteristics of an XML document (that I’m likely to forget)
- element (or tag_names) themselves ARE NOT unique
- within a given element, attribute name ARE unique
- elements can be empty and expressed as follows
- a “well-formed” XML follows a simple set of syntactic rules (doesn’t have any syntax errors)
What does DTD stand for?
Document type definition
What is the importance of XML schema?
Its important for the transfers of data.
It makes it possible for a site to interpret the XML data it receives from another site. Since each site can define its own tags a separate site needs some manner of interpreting the meaning of those tags
On a basic level, what is a DTD?
is a mechanism for specifying an XML schema
it defines the structure and the legal elements and attributes of an XML document
The difference between a “well-formed” and “valid” XML document?
well-formed means syntactically correct, whereas valid means that it’s consistent with the DTD
The 5 entities of an XML document as seen by a DTD
elements attributes entities PCDATA CDATA
What is an XML entity?
Entities are used to define shortcuts to special characters.
Entities can be declared internal or external.
entities typically represent one of the following:
- a character that has special meaning in the XML document
- frequently repeated strings or characters
- large blocks of text
These entities are replaced by whatever they represent (aka “expanded”) when parsed by an XML parser
What is PCDATA
parsed character data
This will be parsed by the XML parser
The parser will look through the PCDATA for entities and expand them and look for tag to treat as markup
What is CDATA
character data
this data WILL NOT be parsed by the XML parser
tags in here will not be treated as markup and entities will not be expanded
The basic syntax for declaring element in DTD?
What is the “category” in a DTD element declaration?
The “category” specifies what is expected to be found within the element
6 different possibilities for the “category” or an DTD element declaration
EMPTY #PCDATA/#CDATA ANY child elements either/or content mixed content
What does the “EMPTY” category in DTD element declaration mean? How is it expressed syntactically?
the element is expected to be empty (aka to have no contents inside)
What does the “#PCDATA/#CDATA” category in DTD element declaration mean? How is it expressed syntactically?
the element is expected to contain only parsed character data (for #PCDATA) or just character data (for #CDATA)
What does the “ANY” category in DTD element declaration mean? How is it expressed syntactically?
the element is expected to contain any combination of parsable data
What does the “child elements” category in DTD element declaration mean?
the element is expected to contain the named child elements as specified
Which child elements that are to be expected and the quantity of a given child element are expressed with particular syntax