HOME - Recent Changes - Search:

Academic Work


Personal

* pot de départ


dblp


(:twitter:)

-----

[ edit | logout ]
[ help | sandbox | passwd ]

Putting HTML in CDATA

#############################

I had an XML file that I wanted to modify with a Java API and then tranform it to HTML using an XSL stylesheet. During the XML modification I wanted to add an HREF link in a tag:

Original XML:

<someTag>text</someTag>

Desired result after XML modification #1 (wrong!):

<someTag><a href="...">text</a></someTag>

However, this HTML piece cannot be added like that, so we must put it as a CDATA value:

Desired result after XML modification #2 (good):

<someTag><![CDATA[<a href="...">text</a>]]></someTag>

XSL transformation #1:

Text: <xsl:value-of select="someTag" /><br/>

Output of XSL transformation #1:

Text: &lt;a href="..."&gt;text&lt;/a&gt;

Oups, "<" and ">" are escaped. If this is not what we want (as in my case), we need to say it in the XSL file:

XSL transformation #2:

Text: <xsl:value-of select="someTag" disable-output-escaping="yes"/><br/>

Now the output is OK:

Text: <a href="...">text</a>
Cloud City


anime | bash | blogs | bsd | c/c++ | c64 | calc | comics | convert | cube | del.icio.us | digg | east | eBooks | egeszseg | elite | firefox | flash | fun | games | gimp | google | groovy | hardware | hit&run | howto | java | javascript | knife | lang | latex | liferay | linux | lovecraft | magyar | maths | movies | music | p2p | perl | pdf | photoshop | php | pmwiki | prog | python | radio | recept | rts | scala | scene | sci-fi | scripting | security | shell | space | súlyos | telephone | torrente | translate | ubuntu | vim | wallpapers | webutils | wikis | windows


Blogs and Dev.

* Ubuntu Incident
* Python Adventures
* me @ GitHub


Places

Debrecen | France | Hungary | Montreal | Nancy


Notes

full circle | km


Hobby Projects

* Jabba's Codes
* PmWiki
* Firefox
* PHP
* JavaScript
* Scriptorium
* Tutorials
* me @ GitHub


Quick Links


[ edit ]

View - Edit - History - Attach - Print *** Report - Recent Changes - Search
Page last modified on 2010 March 04, 22:42