[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Weird XSLT processor output

Subject: Weird XSLT processor output
From: David Carver <d_a_carver@xxxxxxxxx>
Date: Mon, 10 Nov 2003 14:27:28 -0800 (PST)
dave carver
Okay here is the situation, given the following input XML:
<DGS>
	<BOOKMARKS>
		<TABLEID>
			<BMTABLE>CLAIMANT</BMTABLE>
			<BMDESC>Address 1</BMDESC>
			<BMFIELD>ADDRESS1</BMFIELD>
			<XSLTEMP>&lt;xsl:template
match=&quot;CLAIMANT/ADDRESS1&quot;&gt;&lt;xsl:value-of
select=&quot;.&quot;/&gt;&lt;/xsl:template&gt;</XSLTEMP>
		</TABLEID>
		<TABLEID>
			<BMTABLE>CLAIMANT</BMTABLE>
			<BMDESC>Address 2</BMDESC>
			<BMFIELD>ADDRESS2</BMFIELD>
			<XSLTEMP>&lt;xsl:template
match=&quot;CLAIMANT/ADDRESS2&quot;&gt;&lt;xsl:value-of
select=&quot;.&quot;/&gt;&lt;/xsl:template&gt;</XSLTEMP>
		</TABLEID>
		<TABLEID>
			<BMTABLE>CLAIMANT</BMTABLE>
			<BMDESC>ANUMBER</BMDESC>
			<BMFIELD>ANUMBER</BMFIELD>
			<XSLTEMP>&lt;xsl:template
match=&quot;CLAIMANT/ANUMBER&quot;&gt;&lt;xsl:value-of
select=&quot;.&quot;/&gt;&lt;/xsl:template&gt;</XSLTEMP>
		</TABLEID>
		<TABLEID>
			<BMTABLE>CLMREP</BMTABLE>
			<BMDESC>State</BMDESC>
			<BMFIELD>STATE</BMFIELD>
			<XSLTEMP>&lt;xsl:template
match=&quot;CLMREP/STATE&quot;&gt;&lt;xsl:value-of
select=&quot;.&quot;/&gt;&lt;/xsl:template&gt;</XSLTEMP>
		</TABLEID>
		<TABLEID>
			<BMTABLE>CLMREP</BMTABLE>
			<BMDESC>ID</BMDESC>
			<BMFIELD>REPID</BMFIELD>
			<XSLTEMP>&lt;xsl:template
match=&quot;CLMREP/REPID&quot;&gt;&lt;xsl:value-of
select=&quot;.&quot;/&gt;&lt;/xsl:template&gt;</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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.