[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using XSL to create HTML page from values of attributes

Subject: Re: Using XSL to create HTML page from values of attributes in XML
From: Gary L Peskin <garyp@xxxxxxxxxxxx>
Date: Thu, 06 Jul 2000 12:26:54 -0700
using xsl to generate html
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 &lt; &gt; 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@xxxxxxxx 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="&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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.