www.webdeveloper.com
Results 1 to 2 of 2

Thread: Displaying Value Multiple Times?

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Displaying Value Multiple Times?

    Hi there,

    I am trying to figure out how to get a value entered in an xml file to appear multiple times. For example, I would like to be able to update an xml file with the current year in one place, and have the year appear in the resulting html page multiple times.

    In the following xml file, I was hoping to have the value "2010" appear in place of the "<copydate/>" code in the hmtl page, but it does not. Thank you for any help you can provide.

    Here is the xml file:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="style.xsl"?>

    <cdimageing>
    <notguidebody>
    <notguidehead>Copyright </notguidehead>
    <copyrighttxt>

    This material is copyrighted.

    <date>2010</date>

    </copyrighttxt>

    <copyrightline>
    Copyright xxxxx Corporation. <copydate/> All Rights Reserved.
    </copyrightline>

    </notguidebody>

    <notmainfooter>
    </notmainfooter>

    </cdimageing>





    And here is the xsl file.

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

    <xsl:template match="/">
    <html>
    <head>
    <title>XML XSL Example</title>
    <style type="text/css">

    body {
    margin: 0px;
    background-color: #fffff;
    }

    </style>
    </head>
    <body>

    <h1>Sunrise Laboratory Documentation </h1>
    <p>Select the type of book to view.</p>

    <xsl:apply-templates/>

    </body>
    </html>
    </xsl:template>

    <xsl:variable name="copydate" select="date"/>

    <xsl:template match="notmainheader">

    <xsl:value-of select="$copydate"/>

    <div id="header">
    <h1>This is a title </h1>
    </div>

    </xsl:template>

    <xsl:template match="notguidebody">

    <div id="notguides">

    <h2><xsl:value-of select="notguidehead"/></h2>

    <p><xsl:value-of select="copyrighttxt"/></p>

    <p><xsl:value-of select="copyrightline"/> </p>

    </div>

    </xsl:template>


    <xsl:template match="notmainfooter">

    <div id="footer">


    <p class="copyrt"><a href="copyright.xml">Copyright </a></p></div>

    <div id="footernav">
    <p class="footernav"><a href="../Main.xml">Library Overview</a></p>
    <p class="footernav"><a href="help.xml">Help</a></p>
    <p class="footernav"><a href="contact.xml">Contact Us</a></p>
    </div>
    <div id="logolink"><a target="_blank" href="http://www.xxxx.com/"></a></div>
    </xsl:template>
    </xsl:stylesheet>

  2. #2
    Join Date
    Jan 2010
    Posts
    2

    Displaying Value Multiple Times?

    Well, if there is a way, it's too complicated for a beginner like me, so I will just use a variable in the xsl file instead.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles