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

RE: copy-of "canonicalization" behavior in Xalan (Jav

Subject: RE: copy-of "canonicalization" behavior in Xalan (Java)
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Fri, 23 Jul 2004 08:43:47 -0700 (PDT)
xsl copy of xmlns
Thank you Mike for the explanation...

Regards,
Mukul

--- Michael Kay <mhk@xxxxxxxxx> wrote:
> Attributes and namespaces are quite different things
> in the data model, and
> it's expressly stated in the language spec that you
> can't create namespaces
> by trying to create an attribute with an "xmlns:"
> name.
> 
> XSLT 2.0 has an xsl:namespace instruction that
> allows dynamic construction
> of namespace nodes.
> 
> Michael Kay
> 
> > -----Original Message-----
> > From: Mukul Gandhi [mailto:mukul_gandhi@xxxxxxxxx]
> 
> > Sent: 23 July 2004 13:37
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re:  copy-of "canonicalization"
> behavior in Xalan (Java)
> > 
> > I wrote this stylesheet
> > 
> > <?xml version="1.0"?> 
> > <xsl:stylesheet
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0">
> >  
> > <xsl:output method="xml" /> 
> >  
> > <xsl:template match="node()"> 
> >    <xsl:copy>
> >      <xsl:attribute
> > name="xmlns:{substring-before(name(),':')}">
> >        <xsl:value-of select="namespace-uri()" />
> >      </xsl:attribute>
> >      <xsl:for-each select="@*">
> >        <xsl:attribute name="{name()}">
> >          <xsl:value-of select="." />
> >        </xsl:attribute>
> >      </xsl:for-each>      
> >      <xsl:apply-templates />
> >    </xsl:copy>
> > </xsl:template>
> >   
> > </xsl:stylesheet>
> > 
> > When it is applied to the given XML, Xalan
> produces
> > error 
> > "Could not resolve namespace prefix: xmlns. The
> node
> > will be ignored."
> > 
> > My questions are
> > 1) Is it possible to generate attribute names like
> > xmlns:something (i.e. how to escape special
> meaning of
> > xmlns: in XSLT for namespaces)
> > 2) If this is possible, then is it architecturally
> > correct?
> > 
> > Regards,
> > Muku
> > 
> > --- Matthew McKennirey
> <mmckennirey@xxxxxxxxxxxxxx>
> > wrote:
> > > The copy-of element when processed by Xalan
> (Java)
> > > appears to canonicalize the output, rather than
> > > output the source tree exactly.
> > > 
> > > For specific nodes in the source tree I would
> like
> > > to create an identical copy in the result tree,
> > > including redundant namespace
> > > declarations.
> > > 
> > > Assume a source document like:
> > > 
> > > <foo:root xmlns:foo="http://abc.org/foo#"
> > > xmlns:xyz="http://xyzinc.com/xyz#">
> > > 	<foo:parent xmlns:foo="http://abc.org/foo#">
> > > 		<foo:child
> xmlns:foo="http://abc.org/foo#">more
> > > text</foo:child>
> > > 		<xyz:child
> xmlns:xyz="http://xyzinc.com/xyz#">yet
> > > more text</xyz:child>
> > > 	</xyz:parent>
> > > </foo:root>
> > > 
> > > The namespace declarations on the parent and
> child
> > > nodes are redundant (their namespace prefixes
> have
> > > been bound to a namespace on
> > > the root node).
> > > 
> > > When I use copy-of, such as in the simple
> template
> > > below, in XML Spy using its built in XSLT
> processor
> > > the result tree is an exact
> > > and complete copy of the source tree, redundant
> > > namespace declarations and all, as I would
> expect.
> > > 
> > > <xsl:template match ="/">
> > >   <xsl:copy-of select="(.)"/>
> > > </xsl:template>
> > > 
> > > (I have simplified the template in the extreme
> to
> > > make it clear.)
> > > 
> > > When I run the same template with the Xalan
> (Java)
> > > XSLT processor, which uses a SAX parser, I get a
> > > "cleaned", canonical form of the
> > > source tree as my result, with all redundant
> > > namespace declarations removed.
> > > 
> > > This may appear to be a benefit, but I later
> > > manipulate parts of the result tree (which is
> much
> > > more complex than the simple
> > > example) as separate XML fragments and at that
> point
> > > the namespace declarations are in fact no longer
> > > redundant but critical.
> > > 
> > > I have not been able to find anything in the
> Xalan
> > > documentation which suggests a way to avoid this
> > > canonicalization - perhaps its a
> > > SAX issue? Is there a way to force Xalan to make
> an
> > > exact copy of the source tree, warts and all?
> > > 
> > > 
> > > Thanks




		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

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.