Subject: RE: [xsl] Transforming xml with any namespace From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 25 Nov 2009 14:35:31 -0000 |
First point, it is never necessary to use disable-output-escaping="yes" when using output method="text", because no escaping happens with method="text"; and it is never necessary to use it when outputting the text "=", because that would not be escaped anyway (only & and < are escaped). It looks as if you are using this attribute as magic fairy dust when you don't know what it means. The substantive point: the reason you get output for <ns1:Type2>please dont print me</ns1:Type2> is that you don't have a template rule for this element, and the default template rule causes output of the value of all its text nodes. To suppress this, add the template rule <xsl:template match="text()"/> You led me down the garden path for a while by saying you wanted the output Type2=value2, but I assume that was a typo. It wasted a lot of my time. Regards, Michael Kay http://www.saxonica.com/ http://twitter.com/michaelhkay > -----Original Message----- > From: Anders Viklund [mailto:viklund_anders@xxxxxxxxxxx] > Sent: 25 November 2009 14:22 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Transforming xml with any namespace > > > Hi, > I would like extract name=value for a specific element,for > any namespace. > > How can I make this code work properly? > > Thanks for any ideas! > > > XSL: > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="2.0"> <xsl:output method="text" /> <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match="//*[local-name()='Type1']"> > <xsl:value-of select="local-name(.)"/> <xsl:text > disable-output-escaping="yes">=</xsl:text> <xsl:value-of > select="."/> </xsl:template> </xsl:stylesheet> > > > XML: > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet type="text/xsl" > href="http://something"?><ns0:orderReq > xmlns:ns0="http://somethingelse"> > <ns1:order xmlns:ns1="http://nothing"> > <ns1:orderItems> > <ns1:orderItem> > <ns1:Type1>value1</ns1:Type1> > <ns1:Type1>value2</ns1:Type1> > <ns1:Type2>please dont print me</ns1:Type2> > </ns1:orderItem> > </ns1:orderItems> > </ns1:order> > </ns0:orderReq> > > > OUTPUT: > > > > > Type1=value1 > Type1=value2 > please dont print me > > > > > > DESIRED OUTPUT: > Type1=value1 > Type2=value2 > > _________________________________________________________________ > Keep your friends updatedeven when youre not signed in. > http://www.microsoft.com/middleeast/windows/windowslive/see-it -in-action/social-network-basics.aspx?> ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transforming xml with any, David Carlisle | Thread | [xsl] how to change value of attrib, ivanmacculi\@libero\ |
Re: [xsl] Transforming xml with any, Florent Georges | Date | RE: [xsl] Transforming xml with any, Anders Viklund |
Month |