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

Was it a bug?

Subject: Was it a bug?
From: Frederic Bergeron <fbergeron@xxxxxxxxxxxxx>
Date: Wed, 17 Nov 2010 20:27:33 +0900
 Was it a bug?
Hi,

I have the following XML input file:

<lom xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="http://ltsc.ieee.org/xsd/LOM http://ltsc.ieee.org/xsd/lomv1.0/lom.xsd" xmlns="http://ltsc.ieee.org/xsd/LOM">
</lom>

And the following XSLT transformation file:

<xsl:stylesheet version="1.0"
    xmlns:lom="http://ltsc.ieee.org/xsd/LOM"
    xmlns="http://www.imsglobal.org/xsd/lodeilox_v1p0/digital_LO"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"     
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    exclude-result-prefixes="lom">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="lom:lom" mode="work-description-main-metadata">
        <xsl:element name="{local-name()}" namespace="http://www.mystuff.com">
            <xsl:attribute name="myatt">myval</xsl:attribute>
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="*" mode="work-description-main-metadata">
      <xsl:element name="{local-name()}" namespace="http://www.mystuff.com">
         <xsl:copy-of select="@*"/>
         <xsl:apply-templates select="*|text()"/>
      </xsl:element>
   </xsl:template>

    <xsl:template match="lom:lom">
        <xsl:element name="work">
            <xsl:attribute name="xsi:schemaLocation">http://www.imsglobal.org/xsd/lodeilox_v1p0/digital_LO http://www.imsglobal.org/xsd/imsloilox_v1p0_ilox_work_v1p0.xsd</xsl:attribute>
            <xsl:element name="identifier">myidentifier</xsl:element>
            <xsl:element name="description">
                <xsl:element name="metadata">
                    <xsl:element name="schema">http://ltsc.ieee.org/xsd/LOM/imslode/ilox/work/main</xsl:element>
                    <xsl:apply-templates select="self::*" mode="work-description-main-metadata"/>
                </xsl:element>
            </xsl:element>
        </xsl:element>
    </xsl:template>

</xsl:stylesheet>

When I use Xalan 2.6.0 (the default XSLT processor of the JRE 1.6.0_21-b07, if I'm not mistaken), I get the following output:

<work xmlns="http://www.imsglobal.org/xsd/lodeilox_v1p0/digital_LO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/lodeilox_v1p0/digital_LO http://www.imsglobal.org/xsd/imsloilox_v1p0_ilox_work_v1p0.xsd">
<identifier>myidentifier</identifier>
<description>
<metadata>
<schema>http://ltsc.ieee.org/xsd/LOM/imslode/ilox/work/main</schema>
<ns0:lom xmlns:ns0="http://www.mystuff.com" myatt="myval">
</ns0:lom>
</metadata>
</description>
</work>

When I use Saxon 8.7 or Xalan 2.7.0, I get the following output:

<work xmlns="http://www.imsglobal.org/xsd/lodeilox_v1p0/digital_LO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/lodeilox_v1p0/digital_LO http://www.imsglobal.org/xsd/imsloilox_v1p0_ilox_work_v1p0.xsd">
<identifier>myidentifier</identifier>
<description>
<metadata>
<schema>http://ltsc.ieee.org/xsd/LOM/imslode/ilox/work/main</schema>
<lom xmlns="http://www.mystuff.com" myatt="myval">
</lom>
</metadata>
</description>
</work>

Why, in the first case, do I have a generated prefix ns0 for the lom element and that I don't have one in the second case?  Was it a bug in the oldest version of Xalan?  Or is my XSLT ambiguous? 

Regards,

Frederic Bergeron

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.