Using elements inside XSLT file

M

Max Evans

I have a XML file, which contains itemid-elements, e.g.:
<itemid>3</itemid>
<itemid>12</itemid>
Now I want to convert these IDs to the corresponding name via XSLT. I
thought I could do it this way (XSLT):
<xsl:apply-templates select="itemid" />
<xsl:template match="itemid">
<xsl:value-of select="itemnames[itemid]" />
</xsl:template>
And I'd like to have this itemnames-element also inside the XSLT file
(rather than another XML file):
<itemnames>
<item>chair</item>
<item>table</item>
<item>cupboard</item>
...
</itemnames>

But it doesn't work this way because the XSLT processor searches the XML
file for the itemnames-element but it is inside the XSLT file. Is it
possible to point to the itemnames-element inside of the XSLT file? How?

Thank you in advance!


(Sorry, if this message is shown twice, I accidentally used the wrong
news server at first.)
 
J

Joe Kesselman

possible to point to the itemnames-element inside of the XSLT file? How?

The document() function, when called with no arguments, refers to the
stylesheet document.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top