Jump to content

xsl:include issue


schatham

Recommended Posts

Working with SAP MII using a fairly straightforward xslt transformation. I have one xsl file that uses an include to bring in another xsl file to add something to the transformation. The error I get when I try to do this is: "The markup in the document following the root element must be well-formed."XML:

<?xml version="1.0" encoding="UTF-8"?><Rowset>    <Row>        <ItemNo>00000000001884304</ItemNo>        <ItemDesc>Test Item Description</ItemDesc>    </Row> </Rowset>

The first xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" /> <[b]xsl:include[/b] href="http://myserver:myport/XMII/CM/testuser/Test/testcalls_2.xsl"/><xsl:variable name="wrkitem" select="//ItemNo"/><xsl:template match="Row">     <xsl:call-template name="RowEdit"/></xsl:template><xsl:template name="RowEdit" match="Row">      <Item>	<xsl:element name="Items" use-attribute-sets="RowChange">	      </xsl:element>       </Item></xsl:template><xsl:attribute-set name="RowChange">	<xsl:attribute name="RawItemNo">	      <xsl:value-of select="//ItemNo"/>	</xsl:attribute>	<xsl:attribute name="editedItemNo">		<xsl:call-template name="removeLeadingZeros">			<xsl:with-param name="originalString" select="$wrkitem"/>		</xsl:call-template>	</xsl:attribute>	<xsl:attribute name="ItemDesc">			<xsl:value-of select="//ItemDesc"/>	</xsl:attribute>	<xsl:attribute name="dotties">		<xsl:call-template name="dots">      			<xsl:with-param name="count" select="20"/>    		</xsl:call-template>	</xsl:attribute>	<xsl:attribute name="supernova">		<xsl:call-template name="stars">		</xsl:call-template>	</xsl:attribute></xsl:attribute-set>  <xsl:template name="dots">        <xsl:param name="count" select="1"/>      <xsl:if test="$count > 0">        <xsl:text>.</xsl:text>        <xsl:call-template name="dots">          <xsl:with-param name="count" select="$count - 1"/>        </xsl:call-template>      </xsl:if>  </xsl:template><xsl:template name="removeLeadingZeros">    <xsl:param name="originalString"/>    <xsl:choose>      <xsl:when test="starts-with($originalString,'0')">        <xsl:call-template name="removeLeadingZeros">          <xsl:with-param name="originalString">            <xsl:value-of select="substring-after($originalString,'0' )"/>          </xsl:with-param>        </xsl:call-template>      </xsl:when>      <xsl:otherwise>        <xsl:value-of select="$originalString"/>    </xsl:otherwise>    </xsl:choose>  </xsl:template></xsl:stylesheet>

The contents of the xsl that is included in the above stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template name="stars" match="Item"><Stars>	<xsl:element name="BBB">	     <xsl:text>**********</xsl:text>	</xsl:element></Stars></xsl:template></xsl:stylesheet>

The expected result:

<?xml version="1.0" encoding="UTF-8"?><Item>    <Items ItemDesc="Test Item Description" RawItemNo="00000000001884304" dotties="...................." editedItemNo="1884304" supernova="**********" /></Item>

I believe that the xsl in the include is correctly formed. If I run the transformation without the include (and the corresponding call to the template in it), it runs okay. It's only when I add the include back into it that it gives an error.Furthermore, if I open up a website on my local PC & give permissions to it, it will run the code in the include. It's only within the confines of MII and the URL used there that it gives the above error.Is there any way to display or show what the xsl looks like immediately prior to the transformation? Whenever I've looked at the xsl, it shows only the include line in it, not the (expected) xsl that would show both the initial & the included xsl combined. Any thoughts or advice appreciated.

Link to comment
Share on other sites

I don't know exactly what "SAP MII" is but if you think the error is specific to that tool or environment then I suggest you look for a support or user forum dedicated to that tool or environment.
It's a product from SAP relating to manufacturing. My general question was whether there was a way to "see" what the xsl code was with all the includes in it. As it is, what I'd see should I display the xsl would be the main xsl, with one line that says <xsl:include href="......."/>.What I would want to see would be the main xsl, with the code behind the include also in line with it. I believe the other issue with the well-formed markup error message is relating to how that product extracts the xsl code from the database, and permissions & name resolution at that time...However, my general question (and reason for posting here) was is there any way to see what xsl code (includes & everything) was being generated & applied to a transformation?
Link to comment
Share on other sites

I tried your code samples (after replacing the xsl:include absolute href with a relative URL) with Saxon 6.5.5, Saxon 9.3 and Xalan 2.7 and they all run it without producing fatal error messages. Saxon outputs a couple of warnings respectively recoverable errors caused by the template in the included stylesheet being used to generate attribute contents but nevertheless trying to output element nodes. As for the stylesheet being built with an xsl: include, in theory it is done by replacing the xsl:include in the including stylesheet with all top level instructions in the included stylesheet. Whether any XSLT IDEs or editors have a feature or way to display the resulting stylesheet I don't know.

Link to comment
Share on other sites

  • 5 weeks later...
As for the stylesheet being built with an xsl: include, in theory it is done by replacing the xsl:include in the including stylesheet with all top level instructions in the included stylesheet. Whether any XSLT IDEs or editors have a feature or way to display the resulting stylesheet I don't know.
We discovered that the problem wasn't in xsl - we were doing the includes correctly. The issue turned out to be "where" the includes were coming from. In our case, the xsl that called the include was in a database, and it was trying to call out to a web folder. Neither one had permissions to see the other. I had also tried it in jsimplex (a java app that was a simple xslt editor), and the issue there was when it tried to process the include, it was trying to access it from a folder relative to where I had that installed (which didn't exist). Although it might not be 100% on-topic, I can relay how we were able to address the include issue from within MII if there is any interest.Thanks for the help!S
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...