Passing embedded html-code from xml to html
Added by Anonymous over 16 years ago
Legacy ID: #4866561 Legacy Poster: Bernd Tinkl (berndtinkl)
Hello, I use saxon to format XML-Data to html pages. Everything workes fine. But now I discovered a problem and dont know how to handle it. I like to insert html-kommands in the xml data and this data schould pass through the saxon to the html output. Extracted Sample: The xml-Definition <...> <user-value id="1"> <label>Label 1</label> <value>Value 1-1<br/>Value 1-2<br/></value> </user-value> <user-value id="2"> <label>Label 2</label> <value>Value 2</value> </user-value> </...> The Stylesheet: ... <xsl:message>Value: <xsl:value-of select="/protocol/user-values/user-value[@id=1]/value"/></xsl:message> <xsl:value-of select="/protocol/user-values/user-value[@id=1]/label"/> Expected output: Value: Value 1-1<br/>Value 1-2<br/> <!-- The xsl:message --> Value 1-1<br/>Value 1-2<br/> <!-- In the generated html document --> Produced output: Value: Value 1-1Value 1-2 <!-- The xsl:message --> Value 1-1Value 1-2 <!-- In the generated html document --> One solution would be to use an other data format and format it by the Stylesheet, but we cannnot to this, and I think tehre is a possibility to do what i like to do but I dont find the right way. Thanks for any help Bernd
Replies (1)
RE: Passing embedded html-code from xml to ht - Added by Anonymous over 16 years ago
Legacy ID: #4866651 Legacy Poster: Michael Kay (mhkay)
Firstly, let me recommend the xsl-list at mulberrytech.com as the best place to get coding help with XSLT. This forum is best kept for questions that are specific to the Saxon product. However, your question is a very simple (and frequent) one: use xsl:copy-of in place of xsl:value-of. The xsl:value-of instruction gives you the string value of the operand, which in the case of an element node is the concatenation of all its descendant text nodes.
Please register to reply