xsl-list
[Top] [All Lists]

Re: [xsl] XPath element constructor

2012-08-28 16:03:27
Is there somewhere where you think you can use:

  <xsl:sequence ...>

... but where you cannot use in its place:

  <my-cool-element>foo</my-cool-element>

?

I think not.

And while the function does allow you to return the same sequence multiple times, you start your post with the consideration of XPath having constructors.

The <xsl:sequence> is available to you in an element context when you want to use XPath to build something rather than using XSLT and XML to build something. Hence, XPath doesn't need a constructor to do what I think you were trying first to do.

Does this help?

. . . . . . . . . . Ken

At 2012-08-28 22:55 +0200, =?iso-8859-2?Q?Jakub_Mal=FD?= wrote:
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.


--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>