XSL general question
-
Hi, I am new to XSL and I was hoping someone could help me with a problem I am having. I have an Input.xml file to which I want to apply a xsl stylesheet Style.xsl. I also have a Template.xml file which I want to use as the base for the output file. At the moment, here is what I have: I seem to be doing this backwards, here is what I want A
-
Hi, I am new to XSL and I was hoping someone could help me with a problem I am having. I have an Input.xml file to which I want to apply a xsl stylesheet Style.xsl. I also have a Template.xml file which I want to use as the base for the output file. At the moment, here is what I have: I seem to be doing this backwards, here is what I want A
picazo wrote:
I have an Input.xml file to which I want to apply a xsl stylesheet Style.xsl. I also have a Template.xml file which I want to use as the base for the output file.
So you are trying to use 2 XML files in the XSLT right? There may be support for that in XSLT 2.0 I am not sure. Even if there is there may not be an engine that supports it yet, I don't know. However:
picazo wrote:
I also have a Template.xml file which I want to use as the base for the output
That is what the XSLT is for so you may just be over complicating your solution. You should only need the XSLT file and a single XML input file.
led mike
-
Hi, I am new to XSL and I was hoping someone could help me with a problem I am having. I have an Input.xml file to which I want to apply a xsl stylesheet Style.xsl. I also have a Template.xml file which I want to use as the base for the output file. At the moment, here is what I have: I seem to be doing this backwards, here is what I want A
picazo wrote:
<xsl:template match="@* | node()">
xsl:copy
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>This code is really your problem. You should try matching differently. Instead of doing this, try replacing it with:
<xsl:template match="/">
<TemplateRoot>
<xsl:for-each select="InputRoot/elem">
<xsl:apply-templates select="."/>
</xsl:for-each>
</TemplateRoot>
</xsl:template>The code may not be exactly correct because I was too lazy to test it. I think it's a neat idea to mix two XML files, but it depends on your requirements. In most cases, you would want to adjust the XSL instead of having a template XML file outside, like led mike suggested.