Jump to content

Retrieving The Xml Tag's Name


frederikjan

Recommended Posts

Dear,We are using an XSLT transformation to store translations for products in a database. The translations will be sent to us in an XML like this :<ProductID>1234567890</ProductID><EN>Name</EN><NL>Naam</NL><FR>Nom</FR>etc.My target structure has to be as follows :<ProductID>1234567890</ProductID><Text lang="EN">Name</Text><Text lang="NL">Naam</Text><Text lang="FR">Nom</Text>etc.At the moment I have a lot of static coding so I call a template called 'TEXT' with as two parameters the language (EN/NL/FR/...) and the name. Then I'll create the target nodes using those two parameters. So the creation of the node is dynamic, but the calling of it isn't ... For every language that will be in the file (50 or so now, going to be more) I have a different 'call-template'.Is there a way to do this dynamically? To dynamically retrieve the name of the tag, and if possible, even put it dynamically? For example to create the way back (going from attribute 'lang = 'EN'' to a node <EN />).Kind regards,Frederik-Jan

Link to comment
Share on other sites

Nevermind, I just figured it out on my own:

<xsl:for-each select="/Sentence/*"><xsl:variable name="lang"><xsl:value-of select="name()"/></xsl:variable>

And then continue to use that variable to enter a name or w/ever. To retrieve the contents:

<xsl:value-of select="."/>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...