This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: nesting xml


Please study this example before asking more questions like
your previous ones.

Regards,

Dan
-------------------------------------------------

File: Webquest.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Webquest.xsl"?>
<webquest>
  <text>
    Hello, and welcome to my page!
  </text>
  <image>
    <src>http://www.cwolves.com/images/menu/opt1_on.gif</src>
    <border>0</border>
  </image>
  <hyperlink>
    <url>http://www.yahoo.com</url>
    <text>Yahoo!</text>
  </hyperlink>
  <hyperlink>
    <url>/page2.html</url>
    <image>
      <src>http://www.cwolves.com/images/menu/opt2_on.gif</src>
      <border>1</border>
    </image>
  </hyperlink>
</webquest>

File: Webquest.xsl
<?xml version="1.0"?>

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

 <xsl:template match="/">
  <html>
   <body>
    <xsl:apply-templates select="webquest"/>
   </body>
  </html>
 </xsl:template>

  <xsl:template match="webquest">
   <h1><xsl:value-of select="text"/></h1>
   <img src="{image/src}" border="{image/border}"></img><br/>
   <xsl:for-each select="hyperlink">
    <a href="{url}">
    <xsl:choose>
     <xsl:when test="image">
      <img src="{image/src}" border="{image/border}"/>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="text"/>
     </xsl:otherwise>
    </xsl:choose>
    </a><br/>
   </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]