XML
XML stands for EXtensible Markup Language. XML is extensible because, unlike HTML, the markup symbols are unlimited and self-defining. XML is actually a simpler and easier-to-use subset of the Standard Generalized Markup Language (SGML), the standard for how to create a document structure. It is expected that HTML and XML will be used together in many Web applications. XML markup, for example, may appear within an HTML page.
The Difference Between XML and HTML
XML Attribute
Attributes are used to specify additional information about the element. It may help to think of attributes as a means of specializing generic elements to fit your needs. An attribute for an element appears within the opening tag. If there are multiple values an attribute may have, then the value of the attribute must be specified.
· <element attributeName="value">
XML requires that all XML attributes have a value. This means all attributes have to be equal to something! Below is the correct way to create an attribute in XML.
<Department active="true">
<name>Rani</name>
<Subject>Maths</Subject>
</Department >
XML-NameSpace
The XML namespace is a special type of reserved XML attribute that you place in an XML tag. The reserved attribute is actually more like a prefix that you attach to any namespace you create. This attribute prefix is "xmlns:", which stands for XML NameSpace. The colon is used to separate the prefix from your namespace that you are creating.
Advantages of XML
• Truly Portable Data
• Easily readable by human users
• Very expressive (semantics near data)
• Very flexible and customizable (no finite tag set)
• Easy to use from programs (libs available)
• Easy to convert into other representations
(XML transformation languages)
• Many additional standards and tools
• Widely used and supported
Elements in XML Documents
• Elements: <article> ... </article>
• Elements have a name (article) and a content (...)
• Elements may be nested.
• Elements may be empty: <this_is_empty/>
• Element content is typically parsed character data (PCDATA), i.e., strings with special characters, and/or nested elements (mixed content if both).
• Each XML document has exactly one root element and forms a tree.
• Elements with a common parent are ordered.
Difference between elements and attributes?
• Only one attribute with a given name per element (but an arbitrary number of subelements)
• Attributes have no structure, simply strings (while elements can have subelements)
XML Schema
• XML Schema is an XML application
• Provides simple types (string, integer, dateTime, duration, language, …)
• Allows defining possible values for elements
• Allows defining types derived from existing types
• Allows defining complex types
• Allows posing constraints on the occurrence of elements
• Allows forcing uniqueness and foreign keys
XPath and XQuery
XPath and XQuery are query languages for XML data, both standardized by the W3C and supported by various database products.
Their search capabilities include
• logical conditions over element and attribute content
(first-order predicate logic a la SQL; simple conditions only in XPath)
• regular expressions for pattern matching of element names along paths or subtrees within XML data + joins, grouping, aggregation, transformation, etc. (XQuery only)
X-Path
• XPath is a simple language to identify parts of the XML document (for further processing)
• XPath operates on the tree representation of the document
• Result of an XPath expression is a set of elements or attributes
Elements of Xpath
• An XPath expression usually is a location path that consists of location steps, separated by /:
/article/text/abstract: selects all abstract elements
• A leading / always means the root element
• Each location step is evaluated in the context of a node in the tree, the so-called context node
X-Query
· XQuery is an extremely powerful query language for XML data.
· FOR $var1 IN expr1, $var2 IN expr2, ...
· LET $var3 := expr3, $var4 := expr4, ...
· WHERE condition
· RETURN result-doc-construction
· The FOR clause evaluates expressions and binds the resulting elements to variables. For a given binding each variable denotes exactly one element.
· The LET clause binds entire sequences of elements to variables.
· The WHERE clause evaluates a logical condition with each of the possible variable bindings and selects those bindings that satisfy the condition.
· The RETURN clause constructs, from each of the variable bindings,an XML result tree. This may involve grouping and aggregation and even complete subqueries.
XML stands for EXtensible Markup Language. XML is extensible because, unlike HTML, the markup symbols are unlimited and self-defining. XML is actually a simpler and easier-to-use subset of the Standard Generalized Markup Language (SGML), the standard for how to create a document structure. It is expected that HTML and XML will be used together in many Web applications. XML markup, for example, may appear within an HTML page.
The Difference Between XML and HTML
- XML was designed to transport and store data, with focus on what data is.
- HTML was designed to display data, with focus on how data looks.
- XML is used in many aspects of web development, often to simplify data storage and sharing.
- XML Separates Data from HTML.
- XML is Used to Create New Internet Languages
- XHTML
- WSDL for describing available web services
- WAP and WML as markup languages for handheld devices
- RSS languages for news feeds
- RDF and OWL for describing resources and ontology
- SMIL for describing multimedia for the web
XML Attribute
Attributes are used to specify additional information about the element. It may help to think of attributes as a means of specializing generic elements to fit your needs. An attribute for an element appears within the opening tag. If there are multiple values an attribute may have, then the value of the attribute must be specified.
· <element attributeName="value">
XML requires that all XML attributes have a value. This means all attributes have to be equal to something! Below is the correct way to create an attribute in XML.
<Department active="true">
<name>Rani</name>
<Subject>Maths</Subject>
</Department >
XML-NameSpace
The XML namespace is a special type of reserved XML attribute that you place in an XML tag. The reserved attribute is actually more like a prefix that you attach to any namespace you create. This attribute prefix is "xmlns:", which stands for XML NameSpace. The colon is used to separate the prefix from your namespace that you are creating.
Advantages of XML
• Truly Portable Data
• Easily readable by human users
• Very expressive (semantics near data)
• Very flexible and customizable (no finite tag set)
• Easy to use from programs (libs available)
• Easy to convert into other representations
(XML transformation languages)
• Many additional standards and tools
• Widely used and supported
Elements in XML Documents
• Elements: <article> ... </article>
• Elements have a name (article) and a content (...)
• Elements may be nested.
• Elements may be empty: <this_is_empty/>
• Element content is typically parsed character data (PCDATA), i.e., strings with special characters, and/or nested elements (mixed content if both).
• Each XML document has exactly one root element and forms a tree.
• Elements with a common parent are ordered.
Difference between elements and attributes?
• Only one attribute with a given name per element (but an arbitrary number of subelements)
• Attributes have no structure, simply strings (while elements can have subelements)
XML Schema
• XML Schema is an XML application
• Provides simple types (string, integer, dateTime, duration, language, …)
• Allows defining possible values for elements
• Allows defining types derived from existing types
• Allows defining complex types
• Allows posing constraints on the occurrence of elements
• Allows forcing uniqueness and foreign keys
XPath and XQuery
XPath and XQuery are query languages for XML data, both standardized by the W3C and supported by various database products.
Their search capabilities include
• logical conditions over element and attribute content
(first-order predicate logic a la SQL; simple conditions only in XPath)
• regular expressions for pattern matching of element names along paths or subtrees within XML data + joins, grouping, aggregation, transformation, etc. (XQuery only)
X-Path
• XPath is a simple language to identify parts of the XML document (for further processing)
• XPath operates on the tree representation of the document
• Result of an XPath expression is a set of elements or attributes
Elements of Xpath
• An XPath expression usually is a location path that consists of location steps, separated by /:
/article/text/abstract: selects all abstract elements
• A leading / always means the root element
• Each location step is evaluated in the context of a node in the tree, the so-called context node
X-Query
· XQuery is an extremely powerful query language for XML data.
· FOR $var1 IN expr1, $var2 IN expr2, ...
· LET $var3 := expr3, $var4 := expr4, ...
· WHERE condition
· RETURN result-doc-construction
· The FOR clause evaluates expressions and binds the resulting elements to variables. For a given binding each variable denotes exactly one element.
· The LET clause binds entire sequences of elements to variables.
· The WHERE clause evaluates a logical condition with each of the possible variable bindings and selects those bindings that satisfy the condition.
· The RETURN clause constructs, from each of the variable bindings,an XML result tree. This may involve grouping and aggregation and even complete subqueries.