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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html in xml element is ignored 2

Status
Not open for further replies.

BeckD

Programmer
Apr 16, 2002
53
0
0
GB
Hi

I have an xml file describing a document. The body of the document contains html. I then have an xsl page which transforms the xml. My problem is that I want to the html to be interpreted, not displayed or ignored.

XML File
Code:
<page>
<document>
  <date>09 September 2002</date> 
  <title>Editor Test</title> 
  <body><b>Test</b></body>
  <category>Testing</category> 
  <image /> 
  <file /> 
  <internal />  
</document>
</page>

XSL File
Code:
<p><xsl:value-of select=&quot;page/document/body&quot; /></p>

What happens here is that the bold tags within the body xml tag is seen as another xml tag and not as html, and therefore the output ignores the bold tags altogether and just writes the text.

So I tried putting CData tags around the html so that the xml file looked like:
Code:
<body><![CDATA[ <b>Test</b>]]></body>

But this just displays the html on the page instead of interpreting it.

I have tried using disable-output-escaping in the xsl file, but this does the same thing - either ignores the html or displays it, never actually interprets it.

Am I trying to do the impossible?

Beck
 
XML File
-------------------------------------
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;page.xsl&quot;?>
<page>
<document>
<date>09 September 2002</date>
<title>Editor Test</title>
<body><b>Test</b></body>
<category>Testing</category>
<image />
<file />
<internal />
</document>
</page>



XSL file
----------------------------------
<xsl:stylesheet xmlns:xsl=&quot; version=&quot;1.0&quot;>
<xsl:eek:utput method=&quot;html&quot; version=&quot;4.0&quot; />
<xsl:template match=&quot;/&quot;>
<xsl:apply-templates />
</xsl:template>
<xsl:template match=&quot;page/document/body&quot;>
<p>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match=&quot;b&quot;>
<b>
<xsl:apply-templates />
</b>
</xsl:template>
</xsl:stylesheet>

---------------------------------------------
see
 
Hi

I think you've misunderstood my problem. The <b> html tag was just an example - the xml file is dynamically generated by asp so the html inside the cdata body element could be anything not just
Code:
<b>
.

I want to know how you can put html inside an xml element and have the xsl page read the html rather than ignore it altogether or write it to the page.

Thanks for the try though!

Beck
 
Where you tried to use this:
<p><xsl:value-of select=&quot;page/document/body&quot; /></p>

Try this instead:
<p><xsl:copy-of select=&quot;page/document/body&quot; /></p>

The result will be a direct copy of the &quot;<body>&quot; tag and all its contents to the result document.
 
Hi

Thanks very much! It works! You can have a star!

Beck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top