I want to know whether it is possible to transform Relax NG XML with XSLT. Please give me some tutorial.
I don’t seem to be able to match the grammar-tag in the RelaxNG schema below with <xsl:template match="grammar">
<grammar>
<start>
<element name="html">
<zeroOrMore>
<ref name="section"/>
</zeroOrMore>
</element>
</start>
<define name="section">
<element name="div">
<attribute name="class"><value>section</value></attribute>
<zeroOrMore>
<element name="para">
<text/>
</element>
</zeroOrMore>
<zeroOrMore>
<ref name="subsection"/>
</zeroOrMore>
</element>
</define>
</grammar>
Relax NG is a language for expressing a grammar of XML. W3C XML Schema is also such a language. XSLT however, is a language of transforming XML into another data format. In other words, they cover different grounds. Do you really mean to convert Relax NG into XSLT?
You find quite some XSLT’s that you can use to optimize, transform etc your Relax NG, DTD or XML Schema to / from each other on the Relax NG homepage.
Just guessing: you might actually be after is a tool to validate existing XML by its Relax NG schema. You can do that with any one of the validators.
EDIT, based on your last comment. The reason that your
xsl:templateisn’t hit is most likely because you didn’t specify the RelaxNG namespace. You didn’t show any of your code, but try to apply something like the following to your stylesheet (note that the namespace prefix doesn’t matter and doesn’t need to be in the source XML document):