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]

Using XSL to create HTML page from values of attributes in XML



Hi

I am using IE 5.0 as my XSL processor.

I have a scenario where I have to use XSL to generate an HTML page using the
content and the HTML tags specified in an XML document.
Basically, the content and how to display the content, (for eg, bold or
italicized or <H1> </H1> or <H4> </H4>) are present in the XML document as
eithe nodes or attributes. Let me give you an example:

example.xml
<?xml version="1.0"?>
<?xml-stylesheet href="example.xsl" type="text/xsl"?>
<Name id="3270"
      NameBeginTag="&lt;H1&gt;"
      NameEndTag="&lt;/H1&gt;">
  <Child>Joe</Child>
  <Child>Pete</Child>
</Name>

example.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
 <xsl:template match="/">
  <HTML>
  <head>
  </head>
  <BODY>
    <xsl:for-each select="Name/Child">
      <xsl:value-of select="//Name/@NameBeginTag"/>
      <xsl:value-of select="."/>
      <xsl:value-of select="//Name/@NameEndTag"/>
    </xsl:for-each>
  </BODY>
  </HTML>
  </xsl:template>
</xsl:stylesheet>

This xsl results in a page that looks like this in the browser. Basically the
tags are printed literally on the HTML page..

"<H1> Joe </H1> <H1> Pete </H1> "

I understand what is happening, since the NameBeginTag attribute in the Name
node has the tags literally (&lt.... &gt....), the xsl also prints it
literally..
Could someone please tell me how I can work around this ? In my XML document I
canNOT put the tags <H1> </H1> in the node attributes, as neither
attributes nor nodes can contain < , > symbols.

Later..
Badari







 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]