RE: [xsl] Transforming xml with any namespace

Subject: RE: [xsl] Transforming xml with any namespace
From: Anders Viklund <viklund_anders@xxxxxxxxxxx>
Date: Wed, 25 Nov 2009 15:13:53 +0000
Fantstic, this works the way I want, Thanks!

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 select="*"/>
</xsl:template>
<xsl:template match="*:Type1">
   <xsl:value-of select="local-name(.)"/> <xsl:text>=</xsl:text>
<xsl:value-of select="."/><xsl:text>&#10;</xsl:text>
</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


----------------------------------------
> Date: Wed, 25 Nov 2009 16:03:22 +0100
> From: Martin.Honnen@xxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Transforming xml with any namespace
>
> Anders Viklund wrote:
>> Ok, changed to XSLT 2.0, but still the same problem...
>>
>> XSL:
>>
>>
>>
>>
>>
>>
>>
>> disable-output-escaping="yes">=
>>
>>
>>
>> OUTPUT:
>>
>>
>>
>>
>> Type1=value1
>> Type1=value2
>> please dont print me
>
> The main change you need is
>
> to avoid having the default templates output all text nodes.
> You will then also need to output white space explicitly where you want
> it e.g.
>
>
> =
>
>

>
> --
>
> Martin Honnen
> http://msmvps.com/blogs/martin_honnen/
>

_________________________________________________________________
Keep your friends updatedeven when youre not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/soci
al-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

Current Thread