|
46 | 46 | <!-- Set the main output filename --> |
47 | 47 | <xsl:param name="outputfile" select="'portal.xml'" /> |
48 | 48 |
|
| 49 | + <!-- Set the RNC schema file --> |
| 50 | + <xsl:param name="schemafile"></xsl:param> |
| 51 | + |
49 | 52 | <!-- Set the schemaversion attribute in the output XML --> |
50 | 53 | <xsl:param name="schemaversion">7.0</xsl:param> |
51 | 54 |
|
|
192 | 195 | </xsl:choose> |
193 | 196 | </xsl:template> |
194 | 197 |
|
| 198 | + <xsl:template name="add-pi-for-relaxng"> |
| 199 | + <xsl:variable name="ext" select="substring($schemafile, string-length($schemafile) - 3)" /> |
| 200 | + <xsl:if test="$schemafile != ''"> |
| 201 | + <xsl:variable name="type"> |
| 202 | + <xsl:choose> |
| 203 | + <xsl:when test="$ext = '.rnc'">application/relax-ng-compact-syntax</xsl:when> |
| 204 | + <xsl:when test="$ext = '.rng'">application/xml</xsl:when> |
| 205 | + <xsl:otherwise> |
| 206 | + <xsl:message terminate="yes"> |
| 207 | + <xsl:text>Error: Unknown schema file extension for </xsl:text> |
| 208 | + <xsl:value-of select="$schemafile"/> |
| 209 | + <xsl:text>. Only .rnc and .rng are supported.</xsl:text> |
| 210 | + </xsl:message> |
| 211 | + </xsl:otherwise> |
| 212 | + </xsl:choose> |
| 213 | + </xsl:variable> |
| 214 | + <xsl:processing-instruction name="xml-model"> |
| 215 | + <xsl:value-of select="concat(' href="', $schemafile, '"')"/> |
| 216 | + <xsl:value-of select="concat(' type="', $type, '"')"/> |
| 217 | + </xsl:processing-instruction> |
| 218 | + </xsl:if> |
| 219 | + </xsl:template> |
195 | 220 |
|
196 | 221 |
|
197 | 222 | <!-- ======== General Templates --> |
|
213 | 238 | <xsl:call-template name="write.file"> |
214 | 239 | <xsl:with-param name="filename" select="concat($outputdir, $outputfile)" /> |
215 | 240 | <xsl:with-param name="content"> |
| 241 | + <xsl:call-template name="add-pi-for-relaxng" /> |
216 | 242 | <portal schemaversion="7.0" xmlns:xi="http://www.w3.org/2001/XInclude"> |
217 | 243 | <xsl:apply-templates select="categories" /> |
218 | 244 | <productfamilies> |
|
0 commit comments