Project

Profile

Help

New problem with saxon-he 9.7.0-1 java. Worked in previou... » InsertIncludesAndImports.xsl

stylesheet which causes the problem - John Francis, 2016-01-12 14:53

 
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xsl">

<xsl:output method="xml" indent="yes" />
<xsl:param name="additional" select="document('memory:additional')"/>
<xsl:param name="name"/>

<xsl:template match="@*|*|processing-instruction()|comment()">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()" />
</xsl:copy>
</xsl:template>

<xsl:template match="xs:schema">
<xsl:copy>
<xsl:for-each select="$additional/*/newNamespacePrefixes/entry">
<!-- requires XSLT 2.0 -->
<xsl:namespace name="{./key/text()}" select="./value/text()"/>
</xsl:for-each>
<xsl:apply-templates select="@*" />
<xsl:text>
</xsl:text>
<xsl:comment>Start inserted includes and imports</xsl:comment><xsl:text>
</xsl:text>
<xsl:for-each select="$additional/*/include">
<xs:include schemaLocation="{./@location}"/>
</xsl:for-each>
<xsl:for-each select="$additional/*/import">
<xsl:choose>
<xsl:when test="./@namespace">
<xs:import namespace="{./@namespace}" schemaLocation="{./@location}"/>
</xsl:when>
<xsl:otherwise>
<xs:import schemaLocation="{./@location}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:comment>End inserted includes and imports</xsl:comment><xsl:text>
</xsl:text>
<xsl:apply-templates select="*|text()|processing-instruction()|comment()" />
</xsl:copy>
</xsl:template>
<xsl:template match="xs:schema/xs:complexType[@name=$name]/xs:sequence/*[last()]">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()"/>
<xsl:for-each select="$additional/*/body/*">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
(1-1/4)