Home

XSLT code to create XML output from XML in an <xsl:variable>

Posted by Simon on July 04, 2004 at 12:00 PM

Tags: (none)

Here's some code I just wrote in order to parse out XML from a string in XSLT. In XSLT, URL parameters are received in the string type. You can't just copy them into the output because they will be fully entity encoded. So, let's say you wanted to have a form field where someone could enter XHTML, and then you'd store that into an XML file. Of course you don't want to store <p>whatever...</p> into the file. So you have to actually process the incoming string and then create output XML elements as you go. In order to get you started here's some XSLT code that does an OK job of this:

                                                                       

It's pretty easy to call into, just do something like this:

<xsl:call-template name="parseXMLParam"> <xsl:with-param name="input" select="$url_content"/> </xsl:call-template> 

... and that's about it. I think it should generally work for XHTML, but I think that it may fail if there are nested elements with the same name (e.g. a para inside a para) or nested loops of names. However as I said since that doesn't happen much in XHTML it should be useful for that at least.

Steve Forrest gets a livejournal?

Posted by Simon on July 04, 2004 at 12:00 PM

Tags: (none)

Did Steve Forrest start a livejournal ? Yes he did. It seems however to be mostly about the elections so I am not sure if he will ever use it again.

Browse Old Articles

Tags:

Subscribe to: