• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • 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 BormansCommented:
> <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 BormansCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Can you provide the name or link to a useful book?
0
 
Geert BormansCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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