Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT loop over a set of files in the directory?
    primarykey
    data
    text
    <p>I have a situation where I have a directory full of xsd files that need conversion done to them generate a output file for each of them. I have my stylesheet operating on a single document fine, but I'd like to extend that. Well, for now I haven't using a xslt editor, saxon has installed. here is xslt file:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" &gt; &lt;xsl:output method="text"/&gt; &lt;!--* Ignore anything that looks complicated *--&gt; &lt;xsl:template match="xsd:attribute | xsd:attributeGroup | xsd:group | xsd:schema/xsd:element[@type] | xsd:notation | xsd:annotation "/&gt; &lt;!--* Ignore text nodes (otherwise the output will be * inundated with whitespace) *--&gt; &lt;xsl:template match="text()"/&gt; &lt;!--* Top-level elements with local complex types; those * we want to handle. *--&gt; &lt;xsl:template match = "xsd:schema/xsd:element[xsd:complexType]"&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:template&gt; &lt;!--* Aha! A complex type whose content model we want to turn * into a regular expression *--&gt; &lt;xsl:template match = "xsd:element/xsd:complexType [xsd:sequence | xsd:choice | xsd:all]"&gt; &lt;!--* write out the name for the named regex *--&gt; &lt;xsl:value-of select="concat('&amp;#xA;&amp;#xA;', @name, parent::xsd:element/@name, ' ')"/&gt; &lt;!--* write out the regex *--&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:template&gt; &lt;!--* Simple recursive case: we encounter a model group. *--&gt; &lt;xsl:template match = "xsd:sequence|xsd:choice|xsd:all"&gt; &lt;!--* Parenthesize the group and handle its children. *--&gt; &lt;xsl:text&gt;(&lt;/xsl:text&gt; &lt;xsl:apply-templates/&gt; &lt;xsl:text&gt;)&lt;/xsl:text&gt; &lt;!--* Append *, ?, +, or {min, max}. *--&gt; &lt;xsl:call-template name="occurrence-indicator"/&gt; &lt;!--* If our parent has further children, * append the appropriate connector. *--&gt; &lt;xsl:call-template name="connector"/&gt; &lt;/xsl:template&gt; &lt;!--* An element in a content model. *--&gt; &lt;xsl:template match = "xsd:element[ancestor::xsd:complexType]"&gt; &lt;!--* Write out the element's name. We're lazy so * we don't bother with a QName for a local element. * Also, we don't recur. *--&gt; &lt;xsl:value-of select="concat(@ref, @name)"/&gt; &lt;!--* Handle occurrence indicator and connect * just as for groups. *--&gt; &lt;xsl:call-template name="occurrence-indicator"/&gt; &lt;xsl:call-template name="connector"/&gt; &lt;/xsl:template&gt; &lt;!--* Emit the appropriate occurrence indicator for * a group or element. * Use {min,max}, {min,}, or {n} notation for * non-standard occurrence counts. *--&gt; &lt;xsl:template name="occurrence-indicator"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="(@minOccurs='1' or not(@minOccurs)) and (@maxOccurs='1' or not(@maxOccurs))"&gt; &lt;xsl:text&gt;&lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:when test="@minOccurs='0' and (@maxOccurs='1' or not(@maxOccurs))"&gt; &lt;xsl:text&gt;?&lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:when test="@minOccurs='0' and @maxOccurs='unbounded'"&gt; &lt;xsl:text&gt;*&lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:when test="(@minOccurs='1' or not(@minOccurs)) and @maxOccurs='unbounded'"&gt; &lt;xsl:text&gt;+&lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:when test="@minOccurs=@maxOccurs"&gt; &lt;xsl:value-of select="concat('{', @minOccurs,'}')"/&gt; &lt;/xsl:when&gt; &lt;xsl:when test="@maxOccurs='unbounded'"&gt; &lt;xsl:value-of select="concat('{', @minOccurs,',}')"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="concat('{', @minOccurs, ',', @maxOccurs, '}')"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;xsl:template name="connector"&gt; &lt;!--* Emit the appropriate connector, if we need one. *--&gt; &lt;xsl:if test="following-sibling::*[self::xsd:sequence | self::xsd:choice | self::xsd:all | self::xsd:element]"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="parent::xsd:sequence"&gt; &lt;xsl:text&gt;, &lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:when test="parent::xsd:choice"&gt; &lt;xsl:text&gt; | &lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;xsl:when test="parent::xsd:all"&gt; &lt;xsl:text&gt; &amp;amp; &lt;/xsl:text&gt; &lt;/xsl:when&gt; &lt;/xsl:choose&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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