Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I read this correctly, then what you're trying to do is not straight-forward. There is no "magic" connection between the XML document and the schema, you will have to load the schema in the stylesheet and find the documentation in it.</p> <p>Assuming that at a certain point your XSLT stylesheet is in a position where <code>typewoning</code> is under the context element (i.e. <code>value-of select="typewoning"</code> would output its value), you can do this:</p> <pre><code>&lt;xsl:variable name="schema" select="document('my-schema.xsd')/xsd:schema"/&gt; &lt;xsl:variable name="type" select="$schema//xsd:simpleType[@name = 'TypeWoningEnum']"/&gt; &lt;xsl:variable name="value" select="$type//xsd:enumeration[@value = typewoning]//xsd:documentation"/&gt; &lt;xsl:value-of select="$value"/&gt; </code></pre> <p>Some explanation:</p> <ol> <li>The first step loads the schema into a variable using the XSL document function</li> <li>The second step finds the right type (you could probably get fancier and find the type using the element's type in the document, but then schema validation would have to be on and you need a schema-compliant XSLT engine)</li> <li>The third step finds the documentation value to output, given the content of your <code>typewoning</code> element.</li> </ol> <p>Fourth step writes the result out, use as you wish.</p> <p><strong>Edit:</strong> an alternative, if you are willing to use a schema-compliant XSLT engine, such as the paid for version of <a href="http://www.saxonica.com/" rel="nofollow noreferrer">saxon</a>. Assuming all your enumerations derive from <code>integer</code>, you can try this within the context of some parent node:</p> <pre><code>&lt;xsl:variable name="schema" select="document('my-schema.xsd')/xsd:schema"/&gt; &lt;xsl:for-each select="element(*, xsd:integer)"&gt; &lt;xsl:variable name="type" select="$schema//xsd:simpleType[@name = local-name(current())]"/&gt; &lt;xsl:if test="$type"&gt; &lt;xsl:variable name="value" select="$type//xsd:enumeration[@value = current()/text()]//xsd:documentation"/&gt; &lt;xsl:text&gt;Value: &lt;/xsl:text&gt; &lt;xsl:value-of select="$value"/&gt; &lt;/xsl:if&gt; &lt;/xsl:for-each&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload