• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

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??
0
mte01
Asked:
mte01
  • 3
  • 3
1 Solution
 
Geert BormansInformation 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
0
 
mte01Author Commented:
Yes..it worked!!..Really Amazing!..Thanks for your help!
0
 
Geert BormansInformation 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
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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

Can you provide the name or link to a useful book?
0
 
Geert BormansInformation 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
0
 
mte01Author Commented:
Ahaa I see...thx for the tip!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now