Subject: [xsl] Q: XSLT 1.0 output of namespace From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx> Date: Mon, 16 Aug 2010 14:35:00 +0200 |
Hello, this is a pure XSLT 1.0 question. Below template does the (readable) output of the current node even for attribute and namespace nodes. In the spec the following is stated: "There is no pattern that can match a namespace node, ...". So I tried it with negative matches for node, pi, comment and text. But now the differentiation between namespace node and attribute node ( for output of xnlns:ns1="..." / xmlns="..." / attr="..." ) seems a bit complex to me. Can this be simplified? <xsl:template match="@*"> attribute </xsl:template> <xsl:template name="doOutput"> <xsl:choose> <!-- attribute could be matched, namespace not - handle both --> <xsl:when test="not(node()|processing-instruction()|comment()|text ())"> <xsl:variable name="isAttribute"> <xsl:apply-templates select="."/> </xsl:variable> <xsl:if test="$isAttribute=''"> <xsl:text>xmlns</xsl:text> <xsl:if test="name()">:</xsl:if> </xsl:if> <xsl:value-of select="name()"/> <xsl:text>="</xsl:text> <xsl:value-of select="string()"/> <xsl:text>"</xsl:text> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> Mit besten Gruessen / Best wishes, Hermann Stamm-Wilbrandt Developer, XML Compiler, L3 WebSphere DataPower SOA Appliances ---------------------------------------------------------------------- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] yet another namespace que, Wendell Piez | Thread | Re: [xsl] Q: XSLT 1.0 output of nam, Michael Kay |
Re: [xsl] yet another namespace que, Andrew Welch | Date | Re: [xsl] Q: XSLT 1.0 output of nam, Michael Kay |
Month |