Naming an element programatically in XSLT

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In the typical xsl you create elements as follow

<xsl:for-each select="fname"><FriendlyName></FriendlyName></xsl:for-each

In this case I need to create the name of the element programaticall

<xsl:for-each select="catkeymaster"><xsl:element name= ><--- need to assign the name of element with
something like <xsl:value-of select='catkey' /></xsl:element></xsl:for-each

BUT none of the syntax I have tried works

Any help would be most appreciated

Thanks

Pat
 
Hi PatC,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to generate xsl
programatically. If there is any misunderstanding, please feel free to let
me know.

Since xsl is a kind of Xml, I think you can try to generate the Xsl as Xml
with the XmlTextWriter class. For more information about XmlTextWriter,
please check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemXmlXmlTextWriterClassTopic.asp

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

No I am not trying to generate the XSL programatically. I am trying to
generate XML using XSL but the problem is that I am trying to generate
XML elements where the name is the element is generated programatically.
Please check the first post and let me know if that is still confusing.

Thanks,

PatC
 
Hi PatC,

Since you need to generate the Xml with XSLT, I think you can first
generate '<' with XSL. The character has to be escaped. Then get the name
of the tag from the list and write it as <xsl:value-of....>. After that,
write a '>' character (also escaped). HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi kevin,

Actually there is a way to do this using typical XSL syntax

the code looks like this;

<xsl:for-each select="catkeymaster">
<xsl:variable name="cname" select="rskeyword" />
<xsl:element name="{$cname}">
</xsl:element>
</xsl:for-each>

Thanks for your efforts

PatC
 
Hi PatC,

It was nice to hear that you have had the problem resolved. Thanks for
sharing your experience with all the people here. If you have any
questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top