Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Namespaces (6/11) >

Matching all elements in selected namespace

It is possible to match only elements in the selected namespace. Please note, that aaa is not in any namespace and so match = "aaa" can be used. If match = "*", then nodes in any namespace are matched.

XSLT

      <xsl:stylesheet
                  xmlns:o="oooooo"
                  xmlns:p="pppppp"
                  xmlns:v="vvvvvv"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <zzz>
                        <vvv>
                              <xsl:apply-templates  select="v:*"/>
                        </vvv>
                        <ooo>
                              <xsl:apply-templates  select="o:*"/>
                        </ooo>
                        <ppp>
                              <xsl:apply-templates  select="p:*"/>
                        </ppp>
                  </zzz>
            </xsl:template>

            <xsl:template  match="*">
                  <xsl:copy-of  select="."/>
            </xsl:template>

            <xsl:template  match="p:*">
                  <XYZ>
                        <xsl:copy-of  select="."/>
                  </XYZ>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa
                  xmlns:o="oooooo"
                  xmlns:p="pppppp"
                  xmlns:v="vvvvvv">
            <o:bbb/>
            <v:ccc/>
            <o:ddd/>
            <v:eee/>
            <p:fff/>
            <p:ggg/>
      </aaa>
Output

      <zzz
                  xmlns:o="oooooo"
                  xmlns:p="pppppp"
                  xmlns:v="vvvvvv">
            <vvv>
                  <v:ccc/>
                  <v:eee/>
            </vvv>
            <ooo>
                  <o:bbb/>
                  <o:ddd/>
            </ooo>
            <ppp>
                  <XYZ>
                        <p:fff/>
                  </XYZ>
                  <XYZ>
                        <p:ggg/>
                  </XYZ>
            </ppp>
      </zzz>


Previous chapter: Multiple Outputs
Next chapter: Keys
Previous page: Matching nodes in non-null namespace
Next page: Namespace propagation from source to result

Kevin Carr in Stanton

Natural Skin Care and European Soaps
TickTalk 5
city of stanton
internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks ing suit and swim trunks