Introduction Databases function as data sources for Web applications HTML Used in static Web pages XML, JSON Self-describing documents Dynamic Web pages Chapter focus: XML data model and languages
XML Documents, DTD, and XML Schema (cont’d.) Notation for specifying elements elementname* indicates optional multivalued (repeating) element elementname+ indicates required multivalued (repeating) element elementname? indicates optional single-valued (non-repeating) element elementname indicates required single-valued (non-repeating) element
XML Documents, DTD, and XML Schema (cont’d.) Notation for specifying elements (cont’d.) Type specified by parentheses following the element name !ATTLIST used to specify attributes within the element Parentheses can be nested when specifying elements Bar symbol (e1|e2) indicates either e1 or e2 can appear in the document
XML Schema (cont’d.) XML namespace Defines set of commands that can be used Annotations, documentation, and language used Elements and types Root element First-level elements Specifying element type and min and max occurrences
13.4 Storing and Extracting XML Documents from Databases Use file system or DBMS to store documents as text Use DBMS to store document contents as data elements Design specialized system to store XML data Create or publish custom XML documents from preexisting relational databases This approach explored further in 13.6
13.5 XML Languages Query language standards XPath XQuery Specifying XPath expressions in XML Returns sequence of items satisfying certain pattern Values, elements, or attributes Qualifier conditions Separators Single slash / or double slash //
XPath (cont’d.) Example For COMPANY.XML document stored at location www.company.com/info.XML doc(www.company.com/infor.XML)/company returns company root node and all descendant nodes
Other Languages and Protocols Related to XML Extensible Stylesheet Language (XSL) Extensible Stylesheet Language for Transformations (XSLT) Web Services Description Language (WSDL) Simple Object Access Protocol (SOAP) Resource Description Framework (RDF)
13.6 Extracting XML Documents from Relational Databases XML uses hierarchical (tree) model Common database model is flat relational database Conceptually represent using ER schema University example (follows) Choices for root: course, student, section
Other Steps for Extracting XML Documents from Databases Create SQL query to extract desired information Execute the query Restructure from flat to tree structure Customize query to select single or multiple objects into the document
13.8 Summary Structured, semistructured, and unstructured data Hierarchical data model of XML standard Languages for specifying structure XML DTD and XML schema Approaches for storing XML documents XPath and XQuery languages Mapping issues SQL/XML allows formatting query results as XML data
XML: Introduction To XML, Defining XML Tags, Their Attributes and Values, Document Type Definition, XML Schemas, Document Object Model, XHTML. Parsing XML Data - DOM and SAX Parsers in Java