xsl-list
[Top] [All Lists]

[xsl] XPath element constructor

2012-08-28 15:55:18
Hi, 
lets say, that somewhere in an XSLT context, I want to do this: 

<xsl:sequence select="<my-cool-element>foo</m-cool-element>" />

But that is too insane, so I rewrite it like this:

<xsl:sequence select="element my-cool-element { 'foo' }" />

Only if constructors were supported in XPath. 
But I CAN create new nodes in XSLT context! 
So I end up with: 

<xsl:function name="my:const-my-cool-element" as="element()">
  <const-my-cool-element>foo</const-my-cool-element>
</xsl:function>
.
<xsl:sequence select="my:const-my-cool-element()" />

Yay :(
There is no question, really. 

Jakub.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>