XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
hungry backspaceSubject: Creating dynamically named elements
Author: hungry backspace
Date: 26 Dec 2007 02:51 PM

i've read a few posts on the subject of creating dynamically-named elements using the name() function. that technique seems to work for me, but only in limited applications. specifically, i'm finding that using it is problematic within certain templates. for example, this template is called within another template, which is in turn called by yet another template:

<xsl:template match="quote">
<xsl:for-each select="*">
<xsl:for-each select="*">

<xsl:variable name="itemName">
<xsl:value-of select="php:function('translateItems', string(name()))" />

<xsl:element name="example">
<xsl:value-of select="$itemName" />

<xsl:element name="{$itemName}">
<xsl:value-of select="$itemName" />


the variable assignment to a value that passes through PHP is no problem; i can define that statically and the result is the same, which is this: the next element, <example>, is properly added to the document, and the dynamically generated variable $itemname is properly contained within the element. the element after that, however, causes a runtime error in the XSLT processor, and the only discernible difference to me is that i'm assigning the element name to a variable.

i'm admittedly quite new to XSLT! so there's likely something basic i missed. any advice or comments are greatly appreciated.

thanks very much.

Minollo I.Subject: Creating dynamically named elements
Author: Minollo I.
Date: 26 Dec 2007 06:45 PM
This question seems unrelated to Stylus Studio or out other XML products. You may find better assistance asking your general XSLT question to the XSLT list hosted at mulberrytech dot com.

Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.