XSL

Associate
Joined
17 Dec 2008
Posts
671
XSL is a document to transform an existing XML document into an HTML document.

The ISBNs im trying to add is not appearing.

2enxb2v.jpg



Im trying to add ISBN for books on here *.

Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">

  <xsl:output method="html"/>
  <xsl:template match="/">
  <html>
    <head>
      <title><xsl:value-of select="book_club/club-name" /></title>
      <style type="text/css">

        .bookbox
        {
        border-width: 3px;
        border-style: solid;
        padding: 10px;
        margin: 20px;
        }
        
        .bookIsbn
        {
        font-style: italic;
        }

        .bookTitle
        {
        font-weight: bold;
        }

        .bookAuthor
        {
        }

        .bookPrice
        {
        color: #FF0000;
        }

      </style>
    </head>
    <body>
      <center>
        <h2>TIC Book Club</h2>
      </center>
      <p>Join our Book Club!!</p>
      <p>We've got some superb bargains - here's a few:</p>
      <p>
        <xsl:apply-templates select="/book_club//stock" />                   
      </p>
      <p>There's some real clearance bargains here!</p>
      <xsl:apply-templates select="/book_club//remaindered" />
    </body>
  </html>
  </xsl:template>
  
  
  <xsl:template match="book">
    <div class="bookbox">
    <div class="bookTitle">
      
       <xsl:value-of select="title"/>
    
    </div>
      <div class="bookIsbn">
        
       <xsl:value-of select= 'isbn'/> [SIZE="6"]<--------Im trying to select it here.[/SIZE]
        
      </div>

    <div class="bookAuthor">
      
        <xsl:value-of select="author"/>
      
    </div>

    <div class="bookPrice">
      
        <xsl:value-of select="price"/>
      
    </div>
    </div>
  </xsl:template>
  
</xsl:stylesheet>


*From here

Code:
<?xml version="1.0"?>

<?xml-stylesheet href="doc5-5.xsl" type="text/xsl"?>
<book_club>
    <club_name>TIC Book Club</club_name>
    
    <stock>
        <book isbn="0-13-129014-2"> [SIZE="6"]<----------How do I add this isbn?[/SIZE]
            <title>JAVA How to Program (6th Ed)</title>
            <author>PJ &amp; HM Deitel</author>
            <price>£39.99</price>
        </book>
    
        <book isbn="0-67-232238-2">
            <title>Teach Yourself UML</title>
            <author>J Schmuller</author>
            <price>£9.99</price>
        </book>
    
        <book isbn="0-27-365575-2">
            <title>Practical Business Systems Development using SSADM</title>
            <author>P Weaver, N Lambrou &amp; M Walkley</author>
            <price>£34.99</price>
        </book>
        
        <book isbn="0-67-232422-9">
            <title>XML Primer Plus</title>
            <author>N Chase</author>
            <price>£32.99</price>
        </book>
    </stock>
    
    <remaindered>
        <book isbn="0-78-972476-6">
            <title>XML and Java from Scratch</title>
            <author>N Chase</author>
            <price>£19.99</price>
        </book>
    </remaindered>
    
</book_club>
 
Here you go, spot the difference :)

Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">

  <xsl:output method="html"/>
  <xsl:template match="/">
  <html>
    <head>
      <title><xsl:value-of select="book_club/club-name" /></title>
      <style type="text/css">

        .bookbox
        {
        border-width: 3px;
        border-style: solid;
        padding: 10px;
        margin: 20px;
        }
        
        .bookIsbn
        {
        font-style: italic;
        }

        .bookTitle
        {
        font-weight: bold;
        }

        .bookAuthor
        {
        }

        .bookPrice
        {
        color: #FF0000;
        }

      </style>
    </head>
    <body>
      <center>
        <h2>TIC Book Club</h2>
      </center>
      <p>Join our Book Club!!</p>
      <p>We've got some superb bargains - here's a few:</p>
      <p>
        <xsl:apply-templates select="/book_club//stock" />                   
      </p>
      <p>There's some real clearance bargains here!</p>
      <xsl:apply-templates select="/book_club//remaindered" />
    </body>
  </html>
  </xsl:template>
  
  
  <xsl:template match="book">
    <div class="bookbox">
    <div class="bookTitle">
      
       <xsl:value-of select="title"/>
    
    </div>
      <div class="bookIsbn">
        
       <xsl:value-of select= '@isbn'/>
        
      </div>

    <div class="bookAuthor">
      
        <xsl:value-of select="author"/>
      
    </div>

    <div class="bookPrice">
      
        <xsl:value-of select="price"/>
      
    </div>
    </div>
  </xsl:template>
  
</xsl:stylesheet>
 
Back
Top Bottom