We help IT Professionals succeed at work.

STX element with dynamic name

mte01
mte01 asked
on
Medium Priority
303 Views
Last Modified: 2013-11-19
Hey experts,

  When you create an stx element, the general trend is to give it a hard-coded name such as:
 <stx:element  name="code" >
 
  I as trying to create an element whose name is taken dynamically from the value of a variable, i.e. like this:

 <stx:element  name="$code" > 

 But this doesn't seem to be possible, any idea if this is true?? Creating the name of the element tag dynamically would help me later when a program wants to retrieve values from the outputted file, as this would occur faster than if I have a static name and a different attribute for this name, because in the latter case I would have to do a loop over all the elements in the file....any help on dynamic tag name creation??
Comment
Watch Question

Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
> <stx:element  name="$code" > 

<stx:element  name="{$code}" > 

you can't use a simple XPath (or whatever name is used for the limited XPath available in STX)
directly in the name attribute
you have to enclose it in attribute value templates {}
in order for the expression to be evaluated

cheers

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Yes..it worked!!..Really Amazing!..Thanks for your help!
Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
welcome

there is not too much background information available on STX,
but it helps to read a good XSLT book
(and realise you cannot use some of the non forward functionality)

cheers

Author

Commented:
>>but it helps to read a good XSLT book

Can you provide the name or link to a useful book?
Gertone (Geert Bormans)Information Architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
Mastering XSLT Transformations,
Doug Tidwell
O'Reilly
is a good introductory book, that is consise and easy reading

of course you know that STX is only a subset of XSLT
so not everything will apply

cheers

Author

Commented:
Ahaa I see...thx for the tip!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.