STX element with dynamic name

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??
LVL 3
mte01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
> <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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mte01Author Commented:
Yes..it worked!!..Really Amazing!..Thanks for your help!
Gertone (Geert Bormans)Information ArchitectCommented:
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
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

mte01Author 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 ArchitectCommented:
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
mte01Author Commented:
Ahaa I see...thx for the tip!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.