DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17651>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17651 copy-of inserts extraneous namespace declaration into output xml Summary: copy-of inserts extraneous namespace declaration into output xml Product: XalanJ2 Version: 2.4 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Minor Priority: Other Component: org.apache.xalan.serialize AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Whenever I use the copy-of tag in XSL, the copy takes place correctly, but Xalan2 also adds an attribute value of : xmlns:xsi=http://www.w3.org/2000/10/XMLSchema-instance Testcase : Input XML file : ----------------- Input file begins --------------------- <?xml version = "1.0" encoding = "UTF-8"?> <igs xmlns:xsi = "http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "file:///C:/cygwin/home/zaphod/igs_v4.5.xsd"> <business_topic id = "bt_0001" title = "Optimizing IT performance" position = "09"> <call_ibm phone = "1-800-IBM-7080" ext = "SERVICES"/> <email_ibm text = "" destination = "http://www.ibm.com/services/its/us/eserv.wss/ebrc/6COEDW01/index.html"/> </business_topic> </igs> ------------------------ End of input file --------------------- XSL file : ----------------------- XSL file begins ----------------------- <?xml version="1.0"?> <!DOCTYPE xsl:stylesheet [<!ENTITY newline "
">]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema- Instance" extension-element-prefixes="redirect" version='1.0'> <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="igs"> <xsl:copy> <xsl:for-each select="@*"> <xsl:copy /> </xsl:for-each> <xsl:apply-templates /> </xsl:copy> </xsl:template> <xsl:template match="business_topic"> <xsl:element name="resource"> <xsl:attribute name="id"> <xsl:value-of select="@id" /> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="@title" /> </xsl:attribute> <xsl:attribute name="type"> <xsl:text>business_topic</xsl:text> </xsl:attribute> <xsl:for-each select="child::*"> <xsl:choose> <xsl:when test="name() = 'call_ibm' or name() = 'email_ibm'"> <xsl:copy-of select="." /> </xsl:when> <xsl:otherwise> <xsl:text>---------------- Whoa! What element is this? -----------------</xsl:text> <xsl:value-of select="name()" /> <xsl:text>&newline;</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:element> </xsl:template> </xsl:stylesheet> -------------------------- XSL file ends --------------------------- Invocation syntax : java org.apache.xalan.xslt.Process -in <input file> -xsl <XSL transform code> - out <output file> The JDK is the IBM JDK 1.3.1 for Win2000. C:\cygwin\home\zaphod\content\code>java org.apache.xalan.xslt.Process -v >>>>>>> Xalan Version Xalan Java 2.4.1, <<<<<<< Output file : ---------------------------- Output file begins ------------------------- <?xml version="1.0" encoding="UTF-8"?> <igs xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/cygwin/home/zaphod/igs_v4.5.xsd"> <resource xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-Instance" id="bt_0001" title="Optimizing IT performance" type="business_topic"> <call_ibm xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" phone="1-800- IBM-7080" ext="SERVICES"/> <email_ibm xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" text="" destination="http://www.ibm.com/services/its/us/eserv.wss/ebrc/6COEDW01/index.ht ml"/> </resource> </igs> --------------------------- Output file ends ------------------------------ Problem description : As you can see, despite the document element (igs) having an xmlns:xsi namespace declaration, the copy-of transform persists in producing a declaration for xmlns:xsi on every node that it copies. I have it on good authority that this is not the expected behaviour of Xalan and that the serializer should not redeclare this namespace at each element it copies given that the document element has that namespace defined. Its not incorrect output, but is annoying.
