1

i am trying to code XSLT and xml..

one of the problem i am facing is i actually get the values of my xslt file from the xml file one of the fields like description have html tags

           <span class="text"><xsl:value-of select=BusinessDescription"  >
                </xsl:value-of></span><br />

so its outputting including the html tags like

                    <p> Hello there,</P>
                        <b>Hotel</b>

how do i transform the html on the web browser to show the output of the html tags??

like

Hello there,

Hotel

0

2 Answers 2

1

If I understand this question well, you are asking how to interprete escaped markup not as text but as markup.

The answer is:

This cannot be done in pure XSLT 1.0 or XSLT 2.0 (in XSLT 3.0 / XPath 3.0 there might be a function to parse a string as XML).

To do this you need to write an extension function, that takes a string, parses this as XML document and returns the resulting XML document.

Therefore, instead of:

<xsl:value-of select="BusinessDescription"/>

the code that uses this extension function would look something like this:

<xsl:copy-of select="my:xml-parse(BusinessDescription)"/>

The extension function itself would be written in your favourite PL and will simply create an XmlDocument object and try to load the string (with a method such as LoadXml()), then return this XmlDocument as its result.

Sign up to request clarification or add additional context in comments.

Comments

0

If you could post the XSL and XML (try to reduce them to the smallest code that still produces the problem) we could give a more accurate answer. One likely possibility is that your XSL does not produce the <html><body>...</body></html> tags.

Your HTML content should enclosed inside the <body>...</body> element.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.