[Home] [By Thread] [By Date] [Recent Entries]

  • To: "Pietro Venanzangeli" <pietro.venanzangeli@a...>,<xml-dev@l...>
  • Subject: RE: Insert HTML Page into XML CDATA Tag
  • From: "Joseph Hughes" <jhughes@v...>
  • Date: Mon, 8 Apr 2002 05:55:49 -0700
  • Thread-index: AcHcoJKdr2PDy7CbTmGtOEPWrS7e4ACWcfEA
  • Thread-topic: Insert HTML Page into XML CDATA Tag

I'm not sure why you are using a CDATA section... except that the contents of the CDATA section might not be well-formed in some cases. I'm also not sure what your stylesheet looks like but "xsl:value-of" and "xsl:text" elements can take a "disable-output-escaping='yes'" attribute that should take care of your problem. Something like the following should work.

<xsl:template match="/resources">
   <xsl:value-of disable-output-escaping="yes" select="html"/>
</xsl:template>

Joe

-----Original Message-----
From: Pietro Venanzangeli [mailto:pietro.venanzangeli@a...]
Sent: Friday, April 05, 2002 7:48 AM
To: xml-dev@l...
Subject:  Insert HTML Page into XML CDATA Tag


Hi Guy
I have a very big problem.
I create a little web site and I use XSL + XML to produce output.Now I 
want to add a part of html page into xml tag to use a custom page section.
But i find a problme,

see the example :

I use this xml :

<resources>
    <html><![CDATA[<B>Hello World</B>]]></html>
</resources>

trasform xml with xsl page
and my output into html browser is &lt;B&gt;Hello World&lt;/B&gt;
my  BOLD html tag is not parse by browser  because xslt parser trasform 
my special tag into other tag. I want obtin this output :
<b>Hello World</b>

Can you help me ?


this is my trasformation function :

private Transformer getXSLTransformer (xslFile) throws 
XSLTransformerConfigurationException {
    try {
        Transformer transformer = null;
        tFactory = TransformerFactory.newInstance();
        transformer = tFactory.newTransformer(new 
StreamSource(xslFile)); // load xslFile from disk
    } catch (TransformerConfigurationException tce) {
        throw new XSLTransformerConfigurationException(tce.getMessage());
    }
    return transformer;
}

public String myTrasform(String xml,String xslFile) throws Exception {
    StringWriter outputString = new StringWriter(512);
    Transformer transformer = getXSLTransformer (xslFile);
    transformer.transform(new StreamSource(new StringReader(xml)), new 
StreamResult(outputString));                  
    return outputString.toString();
}

Thank's in advance.



-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member