Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying HTML with xsl

Status
Not open for further replies.

acsooley

Programmer
Nov 13, 2002
32
0
0
CA
I have a xml file like:

<article>
<name>test</name>
<english>
<hr />
<h2>What Others Say About Us</h2>
<p>Does the world know about us? Check out these places:</p>
</english>
<french>
<hr />
<h2>What Others Say About Us</h2>
<p>Does the world know about us? Check out these places:</p>


</french>
</article>

I would like to read the file in xsl and when it comes to the english or french to display it using the html tags.
Is there a way to do this?


Adam
 
Depending on what you want to do with it, use something like this:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="[URL unfurl="true"]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"[/URL] omit-xml-declaration="yes"/>
  <xsl:template match="/">
    <xsl:apply-templates select="article"/>
  </xsl:template>
  <xsl:template match="article">
    <html>
      <head>
        <title>
          <xsl:value-of select="name"/>
        </title>
      </head>
      <body>
        <xsl:apply-templates select="english"/>
        <xsl:apply-templates select="french"/>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="english">
    <div class="english">
      <xsl:copy-of select="*"/>
    </div>
  </xsl:template>
    <xsl:template match="french">
    <div class="french">
      <xsl:copy-of select="*"/>
    </div>
  </xsl:template>
</xsl:stylesheet>

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top