This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Using XSL to create HTML page from values of attributes in XML
- To: xsl-list at mulberrytech dot com, Badarinath_Kopparapu at amat dot com
- Subject: Re: Using XSL to create HTML page from values of attributes in XML
- From: Gary L Peskin <garyp at firstech dot com>
- Date: Thu, 06 Jul 2000 12:26:54 -0700
- Organization: The Firstech Corporation
- References: <88256914.005598CD.00@GWSMTPSCLA02.mis.amat.com>
- Reply-To: xsl-list at mulberrytech dot com
I don't work with IE 5.0 for XSL. However, the problem is that you are
outputting <H1> and </H1> as part of a text node. You might try
including
disable-output-escaping="yes"
on your xsl:value-of elements so that they look like this:
<xsl:value-of select="//Name/@NameBeginTag"
disable-output-escaping="yes" />
This works for me with a W3C parser (xalan).
The basic problem here is that you are assembling a text node which you
may really want to look like an element node with a child text node.
This might work better for you. It eliminates the < > stuff as
well and ensures that the end tag matches the beginning tag:
example.xml
<?xml version="1.0"?>
<?xml-stylesheet href="example.xsl" type="text/xsl"?>
<Name id="3270"
NameBeginTag="H1">
<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:element name="{//Name/@NameBeginTag}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
HTH,
Gary
Badarinath_Kopparapu@amat.com wrote:
>
> 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="<H1>"
> NameEndTag="</H1>">
> <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 (<.... >....), 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