English | Français | Deutsch | Magyar | >> 中文 << | Polski adultinternetusers > Tutorials > XSLT Tutorial
>> 页 16 << | 上一条 | 下一条 | 目录 | 元素索引

本例演示了各种轴(axes)的使用。

XSLT stylesheet 1

XML源码
<source>

<doc>
     <ancprec>
          <p>Preceeding Ancestor.
               <br/>
          </p>
     </ancprec>
     <gf>
          <p>Ancestor.
               <br/>
          </p>
          <pprec choice="a">
               <p>Preceeding Parent.
                    <br/>
               </p>
          </pprec>
          <par>
               <p>Parent.
                    <br/>
               </p>
               <sibprec>
                    <p>Preceeding sibling.
                         <br/>
                    </p>
               </sibprec>
               <me id="id001">
                    <p>Me.
                         <br/>
                    </p>
                    <chprec>
                         <p>Preceeding child.
                              <br/>
                         </p>
                    </chprec>
                    <child idref="id001">
                         <p>Child.
                              <br/>
                         </p>
                         <dprec>
                              <p>preceeding Descendant.
                                   <br/>
                              </p>
                         </dprec>
                         <desc>
                              <p>Descendant.
                                   <br/>
                              </p>
                         </desc>
                         <dfoll>
                              <p>Following Descendant.
                                   <br/>
                              </p>
                         </dfoll>
                    </child>
                    <chfoll>
                         <p>following child.
                              <br/>
                         </p>
                    </chfoll>
               </me>
               <sibfoll>
                    <p>Following Sibling.
                         <br/>
                    </p>
               </sibfoll>
          </par>
          <pfoll>
               <p>Following Parent.
                    <br/>
               </p>
          </pfoll>
     </gf>
     <ancfoll>
          <p>following Ancestor.
               <br/>
          </p>
     </ancfoll>
</doc>

</source>

输出
<html>
  <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  
     <title>Document</title>
  </head>
  <body>
     <H2>Following Axis</H2><b>Following Sibling.<br>
         Following Parent.<br>
         following Ancestor.<br>
         </b><H2>Descendant or Self Axis</H2><b>Me.<br>
         Preceeding child.<br>
         Child. <br>
         preceeding Descendant.<br>
         Descendant.<br>
         Following Descendant.<br>
         following child.<br>
         </b><H2>Descendant  Axis</H2><b>Preceeding child.<br>
         Child. <br>
         preceeding Descendant.<br>
         Descendant.<br>
         Following Descendant.<br>
         following child.<br>
         </b><H2>Self Axis</H2><b>Me.<br>
         </b><H2>Child Axis</H2><b>Preceeding child.<br>
         Child. <br>
         following child.<br>
         </b><H2>Following Axis</H2>
     <p><b>Following Sibling.<br>
            Following Parent.<br>
            following Ancestor.<br>
            </b><br><i>Note the lack of ancestors here? <br>Learned anything
           about document order yet?</i></p>
     <H2>Following Sibling Axis</H2><b>
         Following Sibling.<br>
        
         </b><H2>Attribute Axis</H2><b>id001</b><H2>Parent Axis</H2><b>Parent. <br>
         </b><H2>Ancestor or Self  Axis</H2><b>Ancestor. <br>
         Parent. <br>
         Me.<br>
         </b><H2>Ancestor  Axis</H2><b>Ancestor. <br>
         Parent. <br>
         </b><H2>Preceding Sibling Axis</H2><b>Preceeding sibling.<br>
         </b><H2>Preceeding Axis</H2><b><i>Not Implemented in XT 22 09 99</i></b><H2>Namespace Axis</H2><b><i>Not Implemented in XT 22 09 99</i></b></body>
</html>

用HTML察看
Document Surf Skate Snow Surfing Skateboard

Following Axis

Following Sibling.
Following Parent.
following Ancestor.

Descendant or Self Axis

Me.
Preceeding child.
Child.
preceeding Descendant.
Descendant.
Following Descendant.
following child.

Descendant Axis

Preceeding child.
Child.
preceeding Descendant.
Descendant.
Following Descendant.
following child.

Self Axis

Me.

Child Axis

Preceeding child.
Child.
following child.

Following Axis

Following Sibling.
Following Parent.
following Ancestor.

Note the lack of ancestors here?
Learned anything about document order yet?

Following Sibling Axis

Following Sibling.

Attribute Axis

id001

Parent Axis

Parent.

Ancestor or Self Axis

Ancestor.
Parent.
Me.

Ancestor Axis

Ancestor.
Parent.

Preceding Sibling Axis

Preceeding sibling.

Preceeding Axis

Not Implemented in XT 22 09 99

Namespace Axis

Not Implemented in XT 22 09 99
Kevin Carr

Natural Skin Care European Soaps
Kevin Carr
Mayor Dave Shawver Stanton
Internetusers
This is the website that has all the latest for surf, skate and snow. You can also see it here:. You'll be glad you saw the surf apparel.

Take a moment to visit 1cecilia448 or see them on twitter at 1cecilia448 or view them on facebook at 1cecilia448.

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

XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="/">
     <xsl:apply-templates select="//me"/>
</xsl:template>

<xsl:template match="br">
     <br/>
</xsl:template>

<xsl:template match="me" priority="10">
     <html>
          <head>
               <title>
                    <xsl:text>Document</xsl:text>
               </title>
          </head>
          <body>
               <H2>Following Axis</H2>
               <b>
                    <xsl:apply-templates select="following::*/p"/>
               </b>
               <H2>Descendant or Self Axis</H2>
               <b>
                    <xsl:apply-templates select="descendant-or-self::*/p"/>
               </b>
               <H2>Descendant Axis</H2>
               <b>
                    <xsl:apply-templates select="descendant::*/p"/>
               </b>
               <H2>Self Axis</H2>
               <b>
                    <xsl:apply-templates select="self::*/p"/>
               </b>
               <H2>Child Axis</H2>
               <b>
                    <xsl:apply-templates select="child::*/p"/>
               </b>
               <H2>Following Axis</H2>
               <p>
                    <b>
                         <xsl:apply-templates select="following::*/p"/>
                    </b>
                    <br/>
                    <i>Note the lack of ancestors here?
                         <br/>Learned anything about document order yet?
                    </i>
               </p>
               <H2>Following Sibling Axis</H2>
               <b>
                    <xsl:apply-templates select="following-sibling::*"/>
               </b>
               <H2>Attribute Axis</H2>
               <b>
                    <xsl:apply-templates select="attribute::*"/>
               </b>
               <H2>Parent Axis</H2>
               <b>
                    <xsl:apply-templates select="parent::*/p"/>
               </b>
               <H2>Ancestor or Self Axis</H2>
               <b>
                    <xsl:apply-templates select="ancestor-or-self::*/p"/>
               </b>
               <H2>Ancestor Axis</H2>
               <b>
                    <xsl:apply-templates select="ancestor::*/p"/>
               </b>
               <H2>Preceding Sibling Axis</H2>
               <b>
                    <xsl:apply-templates select="preceding-sibling::*/p"/>
               </b>
               <H2>Preceeding Axis</H2>
               <b>
                    <i>Not Implemented in XT 22 09 99</i>
               </b>
               <H2>Namespace Axis</H2>
               <b>
                    <i>Not Implemented in XT 22 09 99</i>
               </b>
          </body>
     </html>
</xsl:template>


</xsl:stylesheet>


Kevin Carr

Natural Skin Care European Soaps
Kevin Carr
Mayor Dave Shawver Stanton
Internetusers
This is the website that has all the latest for surf, skate and snow. You can also see it here:. You'll be glad you saw the surf apparel.

Take a moment to visit 1cecilia448 or see them on twitter at 1cecilia448 or view them on facebook at 1cecilia448.

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