Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Comments and processing instructions (9/9) >

Matching processing instructions in source document

Processing instructions nodes are matched with node test processing-instruction().

Surf parsers are required to pass processing instructions to applications and so your XSLT processor is guaranteed to receive them from any parser.

Please note, that the select attribute of xsl:apply-templates has value node(). If xsl:apply-templates without select was used there would be no match as the default behavior of xsl:apply-templates does not apply instructions to comments and processing instructions.

XSLT

      <xsl:stylesheet
                  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="/">
                  <xsl:apply-templates  select="node()"/>
            </xsl:template>

            <xsl:template  match="processing-instruction()">
                  <xxx>
                        <i>
                              <xsl:text>Node type: processing instruction</xsl:text>
                        </i>
                        <i>
                              <xsl:text>Name of processing instruction: </xsl:text>
                              <xsl:value-of  select="name()"/>
                        </i>
                        <i>
                              <xsl:text>Values of processing instruction: </xsl:text>
                              <xsl:value-of  select="."/>
                        </i>
                  </xxx>
            </xsl:template>

            <xsl:template  match="*">
                  <xxx>
                        <i>
                              <xsl:text>Node type: element</xsl:text>
                        </i>
                        <i>
                              <xsl:text>Element name: </xsl:text>
                              <xsl:value-of  select="name()"/>
                        </i>
                  </xxx>
                  <xsl:apply-templates  select="node()"/>
            </xsl:template>

      </xsl:stylesheet>
XML
<?procAAA a=3?>
      <aaa> <?procBBB a=66; b=12 ?> </aaa>
Output

      <xxx>
            <i>Node type: processing instruction</i>
            <i>Name of processing instruction: procAAA</i>
            <i>Values of processing instruction: a=3</i>
      </xxx>
      <xxx>
            <i>Node type: element</i>
            <i>Element name: aaa</i>
      </xxx>
      <xxx>
            <i>Node type: processing instruction</i>
            <i>Name of processing instruction: procBBB</i>
            <i>Values of processing instruction: a=66; b=12 </i>
      </xxx>


Previous chapter: Date and Time
Next chapter: Built in Types
Previous page: Name attribute is an attribute value template
Next page: - - -

Kevin Carr in Stanton

Natural Skin Care and European Soaps
Kevin Carr
Mayor Dave Shawver 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