3rdstage's Wiki
m (Protected "On XML" (‎[edit=sysop] (indefinite) ‎[move=sysop] (indefinite)) [cascading])
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
  +
<div class="toclimit-3 right">__TOC__</div>
  +
 
<div class="by-3rdstage">
 
<div class="by-3rdstage">
   
  +
* [http://www.w3.org/standards/techs/xml# W3C XML Current Status]
==Parser==
 
  +
* [http://www.w3.org/TR/xml11/ XML 1.1 Specification]
  +
* [http://www.w3.org/TR/xml/ XML 1.0 Specification]
  +
** [http://www.w3.org/TR/xml/#d0e804 Names and Tokens]
  +
* [http://www.w3.org/TR/xml-names11/ Namespaces in XML 1.1 Specification]
  +
* [http://www.w3.org/TR/xml-names/ Namespaces in XML 1.0 Specification]
  +
* [http://www.w3.org/TR/xml-id/ xml:id Version 1.0]
  +
* [http://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml Uniform Resource Identifier (URI) Schemes]
  +
  +
* [http://www.w3schools.com/xml/ XML Tutorial at W3Schools]
  +
* [http://edutechwiki.unige.ch/en/DTD_tutorial DTD tutorial]
  +
* Excerpt from 'The XML Bible' 2nd edition
  +
** [http://www.cafeconleche.org/books/bible2/chapters/ch17.html XSL Transformations]
  +
** [http://www.cafeconleche.org/books/bible2/chapters/ch18.html XSL Formatting Objects]
  +
** [http://www.cafeconleche.org/books/bible2/chapters/ch19.html XLinks]
  +
** [http://www.cafeconleche.org/books/bible2/chapters/ch20.html XPointers]
  +
** [http://www.cafeconleche.org/books/bible2/chapters/ch24.html Schemas]
  +
  +
* '''Concepts'''
  +
** '''character reference'''
  +
*** a specific character in the ISO/IEC 10646 character set, for example one not directly accessible from available input devices.
  +
*** <code>CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'</code>
  +
** '''entity reference'''
  +
*** the content of a named entity.
  +
*** <code>EntityRef ::= '&' Name ';'</code>
  +
  +
* [http://www.xfront.com/HideVersusExpose.pdf Hide (Localize) Versus Expose Namespaces]
  +
* [http://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references Make DocumentBuilder.parse ignore DTD references]
  +
* [http://www.w3.org/TR/REC-xml/#AVNormalize Attribute-Value Normalization]
  +
* [http://stackoverflow.com/questions/6420522/what-does-normative-and-non-normative-mean-in-reference-to-xml What does normative and non-normative mean in reference to XML](Jun 21 '11)
  +
* [http://stackoverflow.com/questions/10842131/xml-comments-and XML comments and "--"](May 31 '12)
  +
  +
==DOM==
  +
  +
* [http://www.w3.org/DOM/DOMTR W3C DOM Technical Reports]
  +
* [http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/ DOM Level 3 Core Specification]
  +
* [http://www.w3.org/TR/DOM-Level-3-Events/ DOM Level 3 Events Specification]
  +
** [http://www.w3.org/TR/DOM-Level-3-Events/#interface-Event Event interface]
  +
** [http://www.w3.org/TR/DOM-Level-3-Events/#event-types-list List of DOM3 Event Types]
  +
* [https://developer.mozilla.org/en-US/docs/DOM/DOM_Reference DOM Reference at MDN]
  +
** [https://developer.mozilla.org/en-US/docs/Web/API/Window.setInterval window.setInterval]
  +
** [https://developer.mozilla.org/en-US/docs/Web/API/window.setTimeout window.setTimeout]
  +
* [http://msdn.microsoft.com/en-us/library/windows/apps/hh831233.aspx DOM Objects and Events at MSDN]
  +
* [http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMConfiguration DOM configuration parameters]
  +
* [http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html#normalizeDocumentAlgo pseudo code for namespace normalization]
  +
  +
==SAX==
  +
  +
* [http://www.saxproject.org/apidoc/index.html SAX Java API]
  +
* [http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description SAX Features and Properties]
  +
  +
==XML Pull Parsing==
  +
  +
* [http://www.xmlpull.org/ XmlPull project]
  +
  +
==XSLT==
  +
  +
* [http://www.w3.org/TR/xslt20/ XSLT 2.0 Specification]
  +
* [http://www.w3.org/TR/xslt-xquery-serialization/#serparam XSLT 2.0 and XQuery 1.0 Serialization Parameters]
  +
* [http://www.w3.org/TR/xsl11/ XSLT 1.1 Specification]
  +
* [http://www.w3.org/1999/11/xslt10.dtd XSLT DTD]
  +
  +
* [http://www.w3schools.com/xsl/ XSLT Tutorial at W3Schools]
  +
* [http://edutechwiki.unige.ch/en/XSLT_Tutorial_-_Basics XSLT tutorial - basics]
  +
  +
* [http://stackoverflow.com/questions/9030536/re-using-nested-xsl-templates Re-using nested XSL templates]
  +
* [http://www.sw-engineering-candies.com/blog-1/howtotransformtheresultsfromfindbugscheckstyleandpmdintoasinglehtmlreportwithxslt20andjava How to Transform the Results from Findbugs, Checkstyle and PMD to HTML Report with XSLT 2.0 and Java?]
  +
  +
==XPath==
  +
  +
===XPath 3.0===
  +
  +
* [http://www.w3.org/TR/xpath-30/ XPath 3.0 Specification (W3C Candidate Recommendation)]
  +
* [http://www.w3.org/TR/xpath-datamodel-30/ XQuery and XPath Data Model 3.0 (W3C Candidate Recommendation)]
  +
* [http://www.w3.org/TR/xpath-functions-30/ XPath and XQuery Functions and Operators 3.0 (W3C Candidate Recommendation)]
  +
  +
===XPath 2.0===
  +
  +
* [http://www.w3.org/TR/xpath20/ XPath 2.0 Specification (Second Edition)]
  +
** [http://www.w3.org/TR/xpath20/#id-matching-item Matching an ItemType and an Item]
  +
** [http://www.w3.org/TR/xpath20/#id-path-expressions Path Expressions]
  +
** [http://www.w3.org/TR/xpath20/#unabbrev Unabbreviated Syntax]
  +
*** '''<code>node()</code>''' : all the children of the context node (no attribute nodes are returned, because attributes are not children.)
  +
*** '''<code>*</code>''' : all element children of the context node
  +
*** '''<code>text()</code>''' : all text node children of the context node
  +
*** '''<code>@*</code>''' : all the attributes of the context node
  +
** [http://www.w3.org/TR/xpath20/#mapping Operator Mapping]
  +
** [http://www.w3.org/TR/xpath20/#id-sequence-expressions '''Sequence Expressions''']
  +
** [http://www.w3.org/TR/xpath20/#id-for-expressions For expression] (<code>for</code> ~ <code>in</code> expression is in XPath not XQuery !)
  +
  +
* [http://www.w3.org/TR/xpath-datamodel/ XQuery 1.0 and XPath 2.0 Data Model (Second Edition)]
  +
** [http://www.w3.org/TR/xpath-datamodel/#dt-sequence '''Sequence'''] : an ordered collection of zero or more items.
  +
** [http://www.w3.org/TR/xpath-datamodel/#dt-item '''Item'''] : either a node or an atomic value.
  +
** [http://www.w3.org/TR/xpath-datamodel/#Node '''Node''']
  +
*** There are seven kinds of Nodes in the data model: '''<code>document, element, attribute, text, namespace, processing instruction, and comment</code>'''.
  +
  +
* [http://www.w3.org/TR/xpath-functions/ XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)]
  +
** [http://www.w3.org/TR/xpath-functions/#func-node-name '''<code>fn:node-name</code>''']
  +
** [http://www.w3.org/TR/xpath-functions/#func-name '''<code>fn:name</code>''']
  +
** [http://www.w3.org/TR/xpath-functions/#func-local-name '''<code>fn:local-name</code>''']
  +
** [http://www.w3.org/TR/xpath-functions/#func-data '''<code>fn:data</code>''']
  +
** [http://www.w3.org/TR/xpath-functions/#func-string '''<code>fn:string</code>''']
  +
** [http://www.w3.org/TR/xpath-functions/#func-not '''<code>fn:not</code>''']
  +
** [https://www.w3.org/TR/xpath-functions/#func-matches '''<code>fn:matches</code>''']
  +
  +
===XPath 1.0===
  +
  +
* [http://www.w3.org/TR/xpath/ XPath 1.0 Specification]
  +
  +
* [http://en.wikipedia.org/wiki/Xpath#Syntax_and_semantics XPath Syntax and Semantics (at Wikipedia)]
  +
* [https://www.w3schools.com/xml/xpath_intro.asp XPath Tutorial at W3Schools]
  +
* [https://www.w3schools.com/xml/xsl_functions.asp XSLT, XPath, and XQuery Functions]
  +
* [http://edutechwiki.unige.ch/en/XPath_tutorial_-_basics XPath tutorial - basics]
  +
* [http://www.saxonica.com/documentation/#!functions XPath Function Library of Saxon]
  +
  +
* [http://www.informit.com/articles/article.aspx?p=102644 Location Steps and Paths in XPath]
  +
* [http://www.saxonica.com/documentation/#!expressions XPath Expression Syntax]
  +
* [http://stackoverflow.com/questions/122463/how-to-retrieve-namespaces-in-xml-files-using-xpath How to retrieve namespaces in XML files using Xpath]
  +
* [http://stackoverflow.com/questions/2524804/how-do-i-use-xpath-with-a-default-namespace-with-no-prefix How do I use XPath with a default namespace with no prefix?](Mar 26 '10)
  +
* [http://dnovatchev.wordpress.com/2008/11/16/xpath-2-0-gems-find-all-duplicate-values-in-a-sequence-part-2/ XPath 2.0 Gems: Find all duplicate values in a sequence (Part 2)]
  +
  +
==XQuery==
  +
  +
* [http://www.w3.org/TR/xquery-30/ XQuery 3.0 Specification (W3C Candidate Recommendation)]
  +
* [http://www.w3.org/TR/xquery/ XQuery 1.0 Specification]
  +
** [http://www.w3.org/TR/xquery/#id-flwor-expressions FLWOR Expressions]
  +
* [http://www.w3.org/XML/Query/#implementations XML Query Implementations]
  +
  +
* [http://www.w3schools.com/xquery/ XQuery Tutorial at W3Schools]
  +
* [http://edutechwiki.unige.ch/en/XQuery_tutorial_-_basics XQuery tutorial - basics]
  +
* [http://www.xquery.co.uk/tutorial_xquery_get_started/index Get Started With XQuery]
  +
* [http://en.wikibooks.org/wiki/XQuery XQuery on Wikibooks]
  +
* [http://www.xqueryfunctions.com/xq/ FunctX XQuery Function Library]
  +
  +
* [http://www.xquery.com/tutorials/xqj_tutorial/ An XQJ Tutorial: Introduction to the XQuery API for Java]
  +
* [http://www.stylusstudio.com/xquery_flwor.html Blooming FLWOR - An Introduction to the XQuery FLWOR Expression]
  +
* [http://www.saxonica.com/documentation/#!using-xquery/extensions Saxon XQuery Extensions]
  +
  +
==XML Catalogs==
  +
  +
* [https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.htm XML Catalogs 1.1 Specification] (7 October 2005)
  +
* [http://xerces.apache.org/xml-commons/components/resolver/resolver-article.html XML Entity and URI Resolvers]
  +
* [http://www.sagehill.net/docbookxsl/WriteCatalog.html How to write an XML catalog file]
  +
* [http://xerces.apache.org/xml-commons/components/resolver/index.html Apache XML Commons/Resolver/Overview]
  +
  +
==XML Schema==
  +
  +
* [http://www.w3.org/TR/2004/REC-xmlschema-0-20041028/ XML Schema Part 0: Primer Second Edition]
  +
* [http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/ XML Schema Part 1: Structures Second Edition]
  +
* [http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/ XML Schema Part 2: Datatypes Second Edition]
  +
* [http://www.w3.org/TR/2012/REC-xmlschema11-1-20120405/ W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures]
  +
* [http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/ W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes]
  +
** [http://www.w3.org/TR/xmlschema11-1/#cAssertions The Assertion Schema Component]
  +
** [http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-datatypes Built-in Datatypes of XSD 2nd Ed.]
  +
  +
* [http://www.w3schools.com/schema/ XML Schema Tutorial at W3Schools]
  +
* [http://www.xfront.com/BestPracticesHomepage.html XML Schemas: Best Practices]
  +
* [http://www.xmlpatterns.com/ Develop effective XML documents using structural design patterns]
  +
* An introduction to XML Schema 1.1
  +
** [http://www.ibm.com/developerworks/xml/library/x-xml11pt1/ Part 1: An overview of the key improvements over XML Schema 1.0 and an in-depth look at datatypes]
  +
** [http://www.ibm.com/developerworks/library/x-xml11pt2/ Part 2: Co-occurence constraints using XPath 2.0]
  +
** [http://www.ibm.com/developerworks/xml/library/x-xml11pt3/ Part 3: Evolve your schema with powerful wildcard support]
  +
* [http://www.xfront.com/xml-schema-1-1/ XML Schema 1.1 Tutorial]
  +
  +
* [http://www.xfront.com/Versioning.pdf What's the best way to version schemas?]
  +
* [http://www.stylusstudio.com/xmldev/200109/post10080.html XML Schemas: Best Practices ? Versioning]
  +
* [http://www.w3.org/TR/xmlschema-0/#po.xsd Sample schema - Purchase Order schema from XML Schema specification]
  +
* [http://stackoverflow.com/questions/1253609/difference-between-xsdkey-and-xsdunique Difference between xsd:key and xsd:unique]
  +
* [http://www.xml.com/lpt/a/987 Enforcing Association Cardinality] (June 26, 2002)
  +
* [http://wiki.apache.org/xerces/XML_Schema_1.1_Assertions XML Schema 1.1 Assertions]
  +
* [http://xerces.apache.org/xerces2-j/faq-xs.html#faq-2 How Xerces-J uses an XPath 2.0 engine for XML Schema 1.1 assertions and type alternatives?]
  +
* [http://www.xfront.com/composition-versus-subclassing.html Composition versus Subclassing]
  +
* [http://www.liquid-technologies.com/SmarterTrack/KB/a79/creating-a-unique-constrant-with-an-xsd.aspx Creating a Unique Constrant with an XSD]
  +
* [http://www.coderanch.com/t/489588/XML/XML-schema-unique-validation-working XML schema unique validation is not working]
  +
* [http://docs.sdl.com/LiveContent/content/en-US/API%20references%20for%20SDL%20Xopus-v2/GUID-9E671376-FAAB-4B4A-BA1A-0320ABB73625 Best Practices- XSD]
  +
* [http://stackoverflow.com/questions/19361553/minoccurs-and-maxoccurs-inside-choice <code>minOccurs</code> and <code>maxOccurs</code> inside <code>choice</code>](Oct 14 '13)
  +
* [http://stackoverflow.com/questions/19863952/xml-schema-maxoccurs-within-choice-element XML Schema - <code>maxOccurs</code> within <code>choice</code> element](Nov 8 '13)
  +
  +
===XML Schema samples===
  +
  +
* [http://www.w3.org/2001/XMLSchema.xsd schema for XML Schema]
  +
* [http://www.w3.org/2007/schema-for-xslt20.xsd schema for XSLT 2.0 stylesheets]
  +
* [http://www.docbook.org/xml/5.0/xsd/ DocBook V5.0 W3C XML Schema]
  +
* [http://www.docbook.org/xsd/4.5/ DocBook V4.5 W3C XML Schema]
  +
* [http://www.springframework.org/schema/beans/spring-beans-3.0.xsd Spring XML Beans Schema, version 3.0]
  +
* [http://www.onvif.org/onvif/ver10/schema/onvif.xsd ONVIF Schema]
  +
* [http://ftp.onem2m.org/XML/Release-1/ oneM2M Release 1 Schemas]
  +
  +
==RELAX NG==
  +
  +
* [http://www.relaxng.org/ RELAX NG home page]
  +
* [http://www.relaxng.org/spec-20011203.html RELAX NG Specification]
  +
* [http://www.relaxng.org/compact-20021121.html RELAX NG Compact Syntax]
  +
* [http://www.relaxng.org/compact-tutorial-20030326.html RELAX NG Compact Syntax Tutorial]
  +
* [http://books.xmlschemata.org/relaxng/page2.html 'RELAX NG'](Book written by Eric van der Vlist)
  +
  +
* RELAX NG Samples
  +
** [http://www.docbook.org/xml/5.0/rng/ DocBook V5.0 RELAX NG]
  +
** [http://www.docbook.org/rng/4.5/ DocBook V4.5 RELAX NG]
  +
  +
==Schematron==
  +
  +
* [http://www.schematron.com/iso/Schematron.html Schematron specification final committee draft]
  +
* [http://www.data2type.de/en/xml-xslt-xslfo/schematron/schematron-reference/ Schematron reference]
  +
  +
* [http://www.data2type.de/en/xml-xslt-xslfo/schematron/schematron-introduction/ '''Schematron introduction''']
  +
* [http://www.xml.com/lpt/a/1318 '''An Introduction to Schematron'''](November 12, 2003)
  +
* [http://www.dpawson.co.uk/schematron/ ISO Schematron tutorial]
  +
  +
* [http://www.ibm.com/developerworks/library/x-stron/ '''Discover the flexibility of Schematron abstract patterns'''](08 October 2004)
  +
* [http://www.topologi.com/resources/schtrn_xsd_paper.html Combining Schematron with other XML Schema languages](2010)
  +
* [http://msdn.microsoft.com/en-us/library/aa468554.aspx#schematron_topic3 Combining Schematron with W3C XML Schema Validation](MSDN, September 2004)
  +
  +
==Web Services Notification==
  +
  +
* Web Services Notification : a set of specifications that standardise the way Web services interact using "Notifications" or "Events".
  +
* [https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wsn OASIS Web Services Notification (WSN) TC]
  +
* '''WS-BaseNotification 1.3'''
  +
** [http://docs.oasis-open.org/wsn/wsn-ws_base_notification-1.3-spec-os.pdf Specification]
  +
** [http://docs.oasis-open.org/wsn/b-2.xsd XML Schema]
  +
** [http://docs.oasis-open.org/wsn/bw-2.wsdl WSDL]
  +
* '''WS-BrokeredNotification 1.3'''
  +
** [http://docs.oasis-open.org/wsn/wsn-ws_brokered_notification-1.3-spec-os.pdf Specification]
  +
** [http://docs.oasis-open.org/wsn/br-2.xsd XML Schema]
  +
** [http://docs.oasis-open.org/wsn/brw-2.wsdl WSDL]
  +
* '''WS-Topics 1.3'''
  +
** [http://docs.oasis-open.org/wsn/wsn-ws_topics-1.3-spec-os.pdf Specification]
  +
** [http://docs.oasis-open.org/wsn/t-1.xsd XML Schema]
  +
  +
==DocBook==
  +
  +
* [http://docbook.org/tdg51/en/html/ "DocBook 5.1: The Definitive Guide" by Norman Walsh]
  +
* [http://www.docbook.org/tdg/en/html/docbook.html "DocBook: The Definitive Guide" by Norman Walsh and Leonard Muellner]
  +
* [http://www.sagehill.net/docbookxsl/ "DocBook XSL: The Complete Guide 4th Edition" by Bob Stayton]
  +
* [http://docbook.sourceforge.net/release/xsl/current/doc/reference.html DocBook XSL Stylesheets: Reference Documentation]
  +
  +
* [http://www.dpawson.co.uk/docbook/index.html Docbook FAQ]
  +
  +
==Dublin Core Metadata==
  +
  +
* [http://en.wikipedia.org/wiki/Dublin_Core Dublin Core at Wikipedia]
  +
** The Dublin Core Schema is a small set of vocabulary terms that can be used to describe web resources (video, images, web pages, etc.), as well as physical resources such as books or CDs, and objects like artworks.
  +
* [http://dublincore.org/documents/dcmi-terms/ DCMI Metadata Terms]
  +
* [http://dublincore.org/documents/dces/ Dublin Core Metadata Element Set, Version 1.1]
  +
* [http://wiki.dublincore.org/index.php/User_Guide Dublin Core User Guide]
  +
* [http://dublincore.org/documents/dc-xml-guidelines/ Guidelines for implementing Dublin Core in XML]
  +
* [http://dublincore.org/documents/dc-html/ Expressing Dublin Core metadata using HTML/XHTML meta and link elements]
  +
* Simple Dublin Core
  +
** [http://dublincore.org/documents/2000/11/dcmes-xml/ An XML Encoding of Simple Dublin Core Metadata]
  +
** [http://dublincore.org/schemas/xmls/simpledc20021212.xsd Simple Dublin Core XML Schema]
  +
  +
==GraphML==
  +
  +
* [http://graphml.graphdrawing.org/primer/graphml-primer.html GraphML Primer]
  +
* [http://graphml.graphdrawing.org/specification.html GraphML Specification]
  +
  +
* [http://www.svgopen.org/2003/papers/ComparisonXML2SVGTransformationMechanisms/ Comparison between XML to SVG Transformation Mechanisms]
  +
  +
==WADL==
  +
  +
* WADL(Web Application Description Language) : a XML description of a deployed RESTful web application.
  +
  +
* [http://www.w3.org/Submission/wadl/ WADL Specification]
  +
* [https://wadl.java.net/ java.net WADL project]
  +
  +
==XAML==
  +
  +
* XAML(eXtensible Application Markup Language) : a declarative XML-based language developed by Microsoft that is used for initializing structured values and objects.
  +
  +
* [https://msdn.microsoft.com/en-us/library/cc189036.aspx XAML]
  +
* [https://msdn.microsoft.com/en-us/library/ee855815.aspx Markup Extensions for XAML Overview]
  +
* [https://msdn.microsoft.com/library/ms747254(v=vs.100).aspx Markup Extensions and WPF XAML (.NET Framework 4)]
  +
  +
==Tips and Tricks==
  +
  +
===Java and XML===
   
===Identifying the implementation of JAXP in use===
+
====Identifying the implementation of JAXP in use====
   
 
<syntaxhighlight lang="java" enclose="div">
 
<syntaxhighlight lang="java" enclose="div">
Line 29: Line 306:
 
</syntaxhighlight>
 
</syntaxhighlight>
   
  +
====Combining schema and validation====
   
  +
* [https://github.com/apache/oozie/blob/master/core/src/main/java/org/apache/oozie/service/SchemaService.java <code>org.apache.oozie.service.SchemaService.java</code>]
==Schema==
 
   
  +
===XQuery===
* [https://github.com/apache/oozie/blob/master/core/src/main/java/org/apache/oozie/service/SchemaService.java Combining schema and validation example : <code>org.apache.oozie.service.SchemaService.java</code>]
 
   
  +
====Applying aggregation functions on XQuery's query====
==XQuery==
 
 
===Applying aggregation functions on XQuery's query===
 
   
 
When using the aggregation function such as <code>count</code> with <code>for</code> clause, apply the function
 
When using the aggregation function such as <code>count</code> with <code>for</code> clause, apply the function
Line 53: Line 329:
 
Other functions for sequence, such as <code>index-of</code> or <code>distinct-values</code> can be used in the same way.
 
Other functions for sequence, such as <code>index-of</code> or <code>distinct-values</code> can be used in the same way.
   
===Useful or intelligent expressions of XQuery===
+
====Useful or intelligent expressions of XQuery====
   
 
Think over the following expressions. What are they?
 
Think over the following expressions. What are they?
Line 68: Line 344:
 
</syntaxhighlight>
 
</syntaxhighlight>
   
  +
====Use positional variable with '''<code>order by</code>'''====
===Applying XQuery on HTML===
 
  +
  +
Positional variables are calculated before '''<code>oder by</code>''' process. If you want to use positional variables after ordering, you can make additional query with positional variables on ordered query like inline query of SQL.
  +
  +
<syntaxhighlight lang="xml" line highlight="2,3,4" enclose="div">
  +
<id-list ordered='true'>
  +
for $y at $i in (for $x in $doc//@id
  +
order by string($x)
  +
return $x)
  +
return <id count='{$i}'>{string($y)}</id>
  +
</id-list>
  +
</syntaxhighlight>
  +
  +
====Applying XQuery on HTML====
   
 
Saxon can't parse HTML file directly. But using TagSoup along with Saxon, you can parse HTML and apply XPath or XQuery to access data.
 
Saxon can't parse HTML file directly. But using TagSoup along with Saxon, you can parse HTML and apply XPath or XQuery to access data.
Line 136: Line 425:
 
...
 
...
 
</syntaxhighlight>
 
</syntaxhighlight>
 
   
 
</div>
 
</div>

Latest revision as of 16:18, 20 September 2018

  • Concepts
    • character reference
      • a specific character in the ISO/IEC 10646 character set, for example one not directly accessible from available input devices.
      • CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
    • entity reference
      • the content of a named entity.
      • EntityRef ::= '&' Name ';'

DOM

SAX

XML Pull Parsing

XSLT

XPath

XPath 3.0

XPath 2.0

XPath 1.0

XQuery

XML Catalogs

XML Schema

XML Schema samples

RELAX NG

Schematron

Web Services Notification

DocBook

Dublin Core Metadata

GraphML

WADL

  • WADL(Web Application Description Language) : a XML description of a deployed RESTful web application.

XAML

  • XAML(eXtensible Application Markup Language) : a declarative XML-based language developed by Microsoft that is used for initializing structured values and objects.

Tips and Tricks

Java and XML

Identifying the implementation of JAXP in use

      System.out.printf("%1$s = %2$s\n", 
            "javax.xml.parsers.SAXParserFactory", System.getProperty("javax.xml.parsers.SAXParserFactory"));
      System.out.printf("%1$s = %2$s\n", 
            "javax.xml.parsers.DocumentBuilderFactory", System.getProperty("javax.xml.parsers.DocumentBuilderFactory"));
      System.out.printf("%1$s = %2$s\n", 
            "javax.xml.transform.TransformerFactory", System.getProperty("javax.xml.transform.TransformerFactory"));
      System.out.printf("%1$s = %2$s\n", 
            "javax.xml.xpath.XPathFactory", System.getProperty("javax.xml.xpath.XPathFactory"));
      System.out.printf("%1$s = %2$s\n", 
            "javax.xml.validation.SchemaFactory", System.getProperty("javax.xml.validation.SchemaFactory"));      

      System.out.printf("SaxParserFactory implementation = %1$s\n",
            SAXParserFactory.newInstance().getClass().getName());
      System.out.printf("DocumentBuilderFactory implementation = %1$s\n",
            DocumentBuilderFactory.newInstance().getClass().getName());
      System.out.printf("TransformerFactory implementation = %1$s\n",
            TransformerFactory.newInstance().getClass().getName());
      System.out.printf("XPathFactory implementation = %1$s\n",
            XPathFactory.newInstance().getClass().getName());
      System.out.printf("SchemaFactory implementation = %1$s\n",
            SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).getClass().getName());

Combining schema and validation

XQuery

Applying aggregation functions on XQuery's query

When using the aggregation function such as count with for clause, apply the function to the entire for clause, not return.

The following query returns 10 lines of 1.

for $x in (1 to 10) return count($x)

Maybe, if you want 10, the following query will be right.

count(for $x in (1 to 10) return ($x))

Other functions for sequence, such as index-of or distinct-values can be used in the same way.

Useful or intelligent expressions of XQuery

Think over the following expressions. What are they? These are from the book "XSLT Coookbook" by Sal Mangano.

(50,45,40,34,32,29,-1)[(index-of((('XXL', 'XL', 'L', 'M', 'S', 'XS')), size), 7)[1]]

The following iterates just n times not n2 times.

for $pos in 1 to count($sequence), $item in $sequence[$pos] return $item , $pos

Use positional variable with order by

Positional variables are calculated before oder by process. If you want to use positional variables after ordering, you can make additional query with positional variables on ordered query like inline query of SQL.

<id-list ordered='true'>
   for $y at $i in (for $x in $doc//@id
      order by string($x)
      return $x)
   return <id count='{$i}'>{string($y)}</id>
</id-list>

Applying XQuery on HTML

Saxon can't parse HTML file directly. But using TagSoup along with Saxon, you can parse HTML and apply XPath or XQuery to access data. The sample below shows the overall programming.

package thirdstage.exercise.xml.saxon;

import java.io.File;
import java.io.FileInputStream;
import java.net.URL;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;

import net.sf.saxon.Configuration;
import net.sf.saxon.dom.DocumentBuilderImpl;
import net.sf.saxon.lib.ParseOptions;
import net.sf.saxon.lib.Validation;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.XQueryCompiler;
import net.sf.saxon.s9api.XQueryEvaluator;
import net.sf.saxon.s9api.XQueryExecutable;
import net.sf.saxon.s9api.XdmNode;
import net.sf.saxon.s9api.XdmValue;

import org.ccil.cowan.tagsoup.Parser;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

...

  @Test
  public void testXqueryOnHtmlAlongWithTagSoup() throws Exception{

    Configuration cfg = new Configuration();
    cfg.setSchemaValidationMode(Validation.LAX);
    cfg.setValidation(false);
    cfg.setValidationWarnings(true);
    Processor proc = new Processor(cfg);

    URL url = ClassLoader.getSystemResource("thirdstage/exercise/xml/saxon/krx-stock-code-only-10.html");
    XMLReader xr = new org.ccil.cowan.tagsoup.Parser();
    //xr.setFeature(Parser.namespacesFeature, false);
    Source src = new SAXSource(xr, new InputSource(new FileInputStream(new File(url.toURI()))));
    net.sf.saxon.s9api.DocumentBuilder db = proc.newDocumentBuilder();
    XdmNode input = db.build(src);

    String qr = new StringBuilder()
      .append("declare default element namespace \"http://www.w3.org/1999/xhtml\";\n")
      .append("for $x in /html/body[1]/table[1]/tr/td[1]/child::text() return $x").toString();
    XQueryCompiler xqc = proc.newXQueryCompiler();
    XQueryExecutable xqe = xqc.compile(qr);
    XQueryEvaluator xqev = xqe.load();
    xqev.setSource(input.asSource());

    XdmValue result = xqev.evaluate();

    System.out.printf("The result of query contains %1$d items.\n", result.size());
    System.out.printf(result.toString());
  }

...