Subject: [xsl] Weird XSLT processor output From: David Carver <d_a_carver@xxxxxxxxx> Date: Mon, 10 Nov 2003 14:27:28 -0800 (PST) |
Okay here is the situation, given the following input XML: <DGS> <BOOKMARKS> <TABLEID> <BMTABLE>CLAIMANT</BMTABLE> <BMDESC>Address 1</BMDESC> <BMFIELD>ADDRESS1</BMFIELD> <XSLTEMP><xsl:template match="CLAIMANT/ADDRESS1"><xsl:value-of select="."/></xsl:template></XSLTEMP> </TABLEID> <TABLEID> <BMTABLE>CLAIMANT</BMTABLE> <BMDESC>Address 2</BMDESC> <BMFIELD>ADDRESS2</BMFIELD> <XSLTEMP><xsl:template match="CLAIMANT/ADDRESS2"><xsl:value-of select="."/></xsl:template></XSLTEMP> </TABLEID> <TABLEID> <BMTABLE>CLAIMANT</BMTABLE> <BMDESC>ANUMBER</BMDESC> <BMFIELD>ANUMBER</BMFIELD> <XSLTEMP><xsl:template match="CLAIMANT/ANUMBER"><xsl:value-of select="."/></xsl:template></XSLTEMP> </TABLEID> <TABLEID> <BMTABLE>CLMREP</BMTABLE> <BMDESC>State</BMDESC> <BMFIELD>STATE</BMFIELD> <XSLTEMP><xsl:template match="CLMREP/STATE"><xsl:value-of select="."/></xsl:template></XSLTEMP> </TABLEID> <TABLEID> <BMTABLE>CLMREP</BMTABLE> <BMDESC>ID</BMDESC> <BMFIELD>REPID</BMFIELD> <XSLTEMP><xsl:template match="CLMREP/REPID"><xsl:value-of select="."/></xsl:template></XSLTEMP> </TABLEID> </BOOKMARKS> </DGS> Desired Output format: <DGS> <BOOKMARKS> <TABLE tableid="tablename"> <FIELD fieldid="fieldname"> <DESC>description</DESC> <XSLTEMP> </XSLTEMP> </FIELD> </TABLE> </BOOKMARKS> </DGS> And the following XSLT's: (XSLTA) <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lookup="urn:some.urn" exclude-result-prefixes="lookup"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <lookup:table> <BMTABLE>CMSCASE</BMTABLE> <BMTABLE>CLAIMANT</BMTABLE> <BMTABLE>CLMREP</BMTABLE> <BMTABLE>CMSGROUP</BMTABLE> <BMTABLE>EMPLOYER</BMTABLE> <BMTABLE>EMPREP</BMTABLE> <BMTABLE>HEARING</BMTABLE> <BMTABLE>HEAROFFCR</BMTABLE> <BMTABLE>OTHERCPT</BMTABLE> <BMTABLE>SUBPOENA</BMTABLE> </lookup:table> <xsl:variable name="globalTableNames" select="document('')/*/lookup:table/*"/> <xsl:template match="DGS"> <xsl:element name="DGS"> <xsl:apply-templates select="BOOKMARKS" /> </xsl:element> </xsl:template> <xsl:template match="BOOKMARKS"> <xsl:element name="BOOKMARKS"> <xsl:for-each select="$globalTableNames"> <xsl:element name="TABLE"> <xsl:attribute name="tableid"><xsl:value-of select="."/></xsl:attribute> <xsl:variable name="tablename"><xsl:value-of select="."/></xsl:variable> <xsl:apply-templates select="/DGS/BOOKMARKS/TABLEID[BMTABLE = $tablename]"/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template match="TABLEID"> <test/> <xsl:element name="FIELD"> <xsl:attribute name="fieldid"> <xsl:value-of select="BMFIELD"/> </xsl:attribute> <xsl:element name="DESC"> <xsl:value-of select="BMDESC"/> </xsl:element> <xsl:element name="XSLTEMP"> <xsl:value-of select="XSLTEMP"/> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> (XSLTB) <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lookup="urn:some.urn" exclude-result-prefixes="lookup"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <lookup:table> <BMTABLE>CMSCASE</BMTABLE> <BMTABLE>CLAIMANT</BMTABLE> <BMTABLE>CLMREP</BMTABLE> <BMTABLE>CMSGROUP</BMTABLE> <BMTABLE>EMPLOYER</BMTABLE> <BMTABLE>EMPREP</BMTABLE> <BMTABLE>HEARING</BMTABLE> <BMTABLE>HEAROFFCR</BMTABLE> <BMTABLE>OTHERCPT</BMTABLE> <BMTABLE>SUBPOENA</BMTABLE> </lookup:table> <xsl:variable name="globalTableNames" select="document('')/*/lookup:table/*"/> <xsl:template match="DGS"> <xsl:element name="DGS"> <xsl:apply-templates select="BOOKMARKS"/> </xsl:element> </xsl:template> <xsl:template match="BOOKMARKS"> <xsl:element name="BOOKMARKS"> <xsl:variable name="bookmarks" select="TABLEID"/> <xsl:for-each select="$globalTableNames"> <xsl:element name="TABLE"> <xsl:attribute name="tableid"><xsl:value-of select="."/></xsl:attribute> <xsl:variable name="tablename"> <xsl:value-of select="."/> </xsl:variable> <xsl:variable name="tempNodeset" select="$bookmarks[BMTABLE = $tablename]"/> <xsl:apply-templates select="$tempNodeset"/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template match="TABLEID"> <xsl:element name="FIELD"> <xsl:attribute name="fieldid"><xsl:value-of select="BMFIELD"/></xsl:attribute> <xsl:element name="DESC"> <xsl:value-of select="BMDESC"/> </xsl:element> <xsl:element name="XSLTEMP"> <xsl:value-of select="XSLTEMP"/> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> When run under XML Spy Enterprise 2004, XSLTA and XSLTB both produce the same desired output. However, when XSLTA is run under LibXSLT, Sablotron, and MSXML (have not tested xalan or saxon), the following output is produced: <DGS> <BOOKMARKS> <TABLE tableid="tablename"/> <TABLE tableid="tablename"/> </BOOKMARKS> </DGS> My question is, is XML Spy producing the correct output for XSLTA or are the other three processors not implementing the transformation correctly? Dave ===== "...there is nothing stranger than people." - Anonymous XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] cdata-section-elements - , Abie Hamaoui | Thread | RE: [xsl] Weird XSLT processor outp, Michael Kay |
RE: [xsl] cdata-section-elements - , Abie Hamaoui | Date | [xsl] converting XML to XML problem, Abhijit Junnare |
Month |