Extensible Markup Language II

  • View
    25

  • Download
    0

Embed Size (px)

DESCRIPTION

Extensible Markup Language II. Namespace, XPath and XSL. XML Namespace. NamespaceS. XML Namespaces. Namespaces provide method to avoid element name conflicts Collections of names identified by URIs - PowerPoint PPT Presentation

Transcript

Extensible Stylesheet Language

Extensible Markup Language IINamespace, XPath and XSLNamespaceSXML NamespaceXML NamespacesNamespaces provide method to avoid element name conflictsCollections of names identified by URIsNamespaces allow names within a document to retain their original meanings even when combined with other documentHowever, if you dont need namespaces, dont use themConflict examples

Johan AbdullahAE15562Pioneer Hi-FiPI-032-EX

Namespaces Solution

Johan AbdullahAE15562Pioneer Hi-FiPI-032-EX

NamespacesNamespace declaration:Defined by xmlns attribute

xmlns:prefix = URI

Namespace URI is not used by parser to look for information

My CD Collection Title Artist

Namespace for non-HTML tags (with xsl prefix, marked with red arrows)XPathNavigating XML DocumentXPathXpath language to navigate and find information in XML documentUses path expressions to navigate XML documentsContains a library of standard functions

Xpath Path Expressions/FunctionsXpath uses path expressionsUse path expressions to select nodes/node-sets in XML documentsPath expressions similar to computer file systemXpath includes more than 100 functionsFunctions for string and numeric values, date/time comparison, node/QName manipulation, Boolean values etc.XPath Nodes - terminologySeven kinds of nodes:ElementAttributeTextNamespaceProcessing-instruction (PI)CommentDocument nodesAtomic values nodes without children or parentItems atomic values or nodesXPath Nodes - relationshipTypes of relationship:ParentChildrenSiblingsAncestorsDescendants

XPath SyntaxSelecting nodes

ExpressionDescriptionnodenameSelects all child nodes of the named node/Selects from the root node//Selects nodes in the document from the current node that match the selection no matter where they are .Selects the current node..Selects the parent of the current node@Selects attributesXPath SyntaxPredicates used to find a specific node/node with a specific value

Path ExpressionResults/katalog/kereta [1]Select the first kereta element that is the child of katalog element (in IE, use kereta[0])/katalog/kereta [last()]Select the last kereta element/katalog/kereta [position()50000]Select all the kereta elements of the katalog element with price greater than 50000XPath Wildcards/| operatorWildcards to select unknown XML elements

Use | to select several pathsWildcardDescription*Matches any element node@*Matches any attribute nodenode()Matches any node of any kindPath ExpressionResults//kereta/model | //kereta/hargaSelect all model AND harga elements of all kereta elements//tahun | //ccSelect all the tahun AND cc elementsMore XPath ReferencesXPath Axes - http://www.w3schools.com/xpath/xpath_axes.asp XPath Operators - http://www.w3schools.com/xpath/xpath_operators.aspXPath functions (with XQuery, XSLT) - http://www.w3schools.com/xpath/xpath_functions.aspXPath ExampleUsing Javascript using kereta.xmlEdit the ex1.html , ex2.html and ex3.html filesUnderstand the usage of XPath and JavascriptXSLTExtensible Stylesheet Language TransformationDisplaying XMLXML documents dont carry information about how to display data3 ways to display data:XSLT (Extensible Stylesheet Transformation Language)CSS (Cascading Style Sheet)JavaScriptXSLXSL Extensible Stylesheet LanguageStyle sheets for XMLDescribes how the XML document should be displayedConsisted of:XSLT transforming XML documentsXPath navigating XML documentsXSL-FO formatting XML documentsXSL TransformationXSLT XSL TransformationTransform XML documents to other formats (e.g. XHTML) transform each XML element to XHTML elementSupported by all major browsersMost important part of XSLAllows adding/removing elements and attributes to/from output file, rearranging/sorting elements, perform test etc.

XSLT - TransformationExample of a transformation steps:Start with a raw XML documentDeclare stylesheetCreate XSL style sheetLink style sheet to the XML document

My CD Collection Title Artist

XSLT exampleXSLT ExampleUsing kereta.xmlCreate/Edit the XSLT files to show various combination of sorting, filtering, formatting etc.Understand the usage of XSLTThe End Thank You