<?xml version="1.0" encoding="UTF-8"?>
<!--
	source of XPath guide section shared between Basic and Advanced specifications
-->

    <inform-div1 id="xpath-idioms">  
	<head>XPath 2.0 Idioms</head>
	<p>The following <bibref ref="XPath2.0"/> examples are intended to illustrate the idiomatic use of 
	<bibref ref="XPath2.0"/> by this specification when defining <bibref ref="XMLSchema"/> patterns.</p>

    <xpath-idiom-list summary="XPath 2.0 Idioms">

      <xpath-idiom id="elementFormDefault" xpath="./(@elementFormDefault)">
	returns the <code>elementFormDefault</code> attribute of the <code>xs:schema</code> element
      </xpath-idiom>

    <xpath-idiom id="elementFormDefaultQualified" xpath=".[@elementFormDefault='qualified']/(@elementFormDefault)">
	returns the <code>elementFormDefault</code> attribute of the <code>xs:schema</code> element, where the contents of the <code>elementFormDefault</code> attribute is the string <code>'qualified'</code>.
    </xpath-idiom>

	<xpath-idiom id="mixed-attribute-value" xpath=".//.[@mixed = 'false']/(@mixed)">
	returns the set of <code>mixed</code> attributes contained on any element found beneath the <code>xs:schema</code> element, where the contents of the <code>mixed</code> attribute is the string value <code>'false'</code>.
      </xpath-idiom>

	<xpath-idiom id="parent" xpath=".//xs:element[not(parent::xs:schema)]/xs:complexType">
	returns the <code>xs:complexType</code> element where the parent node is not the element <code>xs:schema</code>.
	</xpath-idiom>

	<xpath-idiom id="wildcard-nodes" xpath=".//xs:annotation/xs:documentation/ (.., ., .//*, .//@*)">
	returns the parent node, the current node, all descendant elements and all descendant attributes for all <code>xs:documentation</code> elements.
	</xpath-idiom>

    <xpath-idiom id="resolve-qname" xpath=".//xs:element/@type[resolve-QName(.,..) = xs:QName('xs:string')]">
	returns the <code>type</code> attribute where the QName value of the <code>type</code> attribute is a local part <code>string</code> in the namespace found by resolving the prefix <code>xs</code> in <specref ref="namespaces"/>, i.e <code>'http://www.w3.org/2001/XMLSchema'</code>.
    </xpath-idiom>

	<xpath-idiom id="resolve-qname-el" xpath=".//xs:element[@name and @type and namespace-uri-from-QName(resolve-QName(@type,.)) != 'http://www.w3.org/2001/XMLSchema' and contains(@type, ':')]/ (., @name, @type)">
     returns the <code>xs:element</code>, <code>name</code> and <code>type</code> attributes where the string value of the <code>type</code> attribute contains a ':' character,
     and the resultant QName value is not the <bibref ref="XML Schema"/> datatypes namespace, i.e. an explicitly qualified datatype in the <code>##targetNamespace</code> or <code>##other</code> namespace.
	</xpath-idiom>


	<xpath-idiom id="not-schemalocation" xpath="./xs:import[@namespace and not(@schemaLocation) and not(@namespace = 'http://www.w3.org/2001/XMLSchema')]/ (., @namespace)">
	returns the <code>xs:import</code> element and <code>namespace</code> attribute for an <code>xs:import</code> element with an absent <code>schemaLocation</code> attribute 
	or one matching the <bibref ref="XMLSchema"/> datatypes namespace.
	</xpath-idiom>


	<xpath-idiom id="not-maxoccurs" xpath=".//xs:element[@minOccurs = '0' and (not(@maxOccurs) or @maxOccurs = '1')]/ (@minOccurs, @maxOccurs)">
	returns the <code>minOccurs</code> and <code>maxOccurs</code> attributes for an <code>xs:element</code> element where the <code>minOccurs</code> 
	attribute has a string value of <code>'0'</code> and the <code>maxOccurs</code> attribute is absent or has a string value of <code>'1'</code>.
	</xpath-idiom>


	<xpath-idiom id="count" xpath=".//xs:sequence[count(xs:element) = 1]/xs:element[@maxOccurs = 'unbounded']/ (., @maxOccurs)">
	returns the <code>xs:element</code> element and <code>maxOccurs</code> attribute
	where a <code>sequence</code> has a single <code>xs:element</code> element that is defined with <code>maxOccurs</code> attribute string value of <code>'unbounded'</code>.
	</xpath-idiom>


	<xpath-idiom id="not-node" xpath=".//xs:element[@name]/xs:complexType[not(node())]/(., .., ../@name)">
	returns the <code>xs:complexType</code> and <code>xs:element</code> element, and the <code>xs:element</code> <code>name</code> attribute where the complexType does not have any child nodes. 
	</xpath-idiom>

	</xpath-idiom-list>


    </inform-div1>

