0

I am writing a stylesheet to convert un-parsed HTML to XSl-FO. I will get a element that has un-parsed html. I want to load the contents of Comment into a document variable:

<Comment>&lt;div align="left"&gt;&lt;font size="4" color="#FF0000"&gt;This is &lt;i&gt;&lt;b&gt;&lt;u&gt;some &lt;/u&gt;&lt;/b&gt;&lt;/i&gt;sample html again&lt;/font&gt;&lt;br&gt;&lt;/div&gt;</Comment>

Which will look like this

<div align="left"><font size="4" color="#FF0000">This is <i><b><u>some </u></b></i>sample html again</font></div>

or formatted:

<div align="left">
    <font size="4" color="#FF0000">This is <i>
            <b>
                <u>some </u>
            </b>
        </i>sample html again</font>
</div>

And try to access the elements with:

<xsl:variable name="html">
    <xsl:value-of select="Comment" disable-output-escaping="yes"/>
</xsl:variable>
<xsl:value-of select="$html//b"/>

But this of course is not working. Is this possible with xslt 1.0?

1 Answer 1

1

No, it's not possible. The content of the Comment node is a single text node that contains a (meaningless) string. There are no "sub-nodes" that XPath can select. The only way to extract information from the string is by using string functions.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.