[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Generating JSP/JSTL
Michael Kay wrote:
It's not possible with pure XSLT to generate XML that isn't namespace-well-formed (for example, XML that uses a namespace prefix that isn't declared). Does JSP/JSTL really require that? I don't fully agree with you here. I'm not sure what "pure" XSLT is about, but instructions like xsl:character-map are part of the core (pure?) XSLT language and can help us in making invalid output. Of course, it is the last thing you should do: create invalid XML and it is not going to help you application in becoming more understandable or even maintainable, but it is very well possible (but not trivial). Here's a go at creating output the way the OP wanted it (though you loose on the indentation): <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f = "http://functions" exclude-result-prefixes="#all" version="2.0"> <xsl:output method="xml" omit-xml-declaration="yes" use-character-maps="non-wellformed"/> <xsl:character-map name="non-wellformed"> <xsl:output-character character="" string="<"/> <xsl:output-character character="" string=">"/> </xsl:character-map> <xsl:template match="/"> <ul> <xsl:sequence select="f:create-non-wellformed-element('c:choose', 'foo')"></xsl:sequence> </ul> </xsl:template> <xsl:function name="f:create-non-wellformed-element"> <xsl:param name="element-name" /> <xsl:param name="content" /> <xsl:value-of select="'', $element-name, ''" separator=""/> <xsl:copy-of select="$content" /> <xsl:value-of select="'', '/', $element-name, ''" separator=""/> </xsl:function> </xsl:stylesheet> Which will produce the following output without producing any error: <ul><c:choose>foo</c:choose></ul> Still, when using JSTL and JSP, this is not going to help you, because JSTL requires the namespace to be bound and the XML to be legal. I'd be very interested to know why the OP wants a type of XML that is not going to work anyway... Nevertheless, in the words of someone whose name I forgot: "It *can* be done with XSLT". Cheers, -- Abel Braaksma
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|