I have an XML configuration file, i want to pull one of the fields from that file and include it on my XSL.
Here are the examples that I have come across:
<xsl:template match="">
<html>
<head>
<title>My Page</title>
<!-- CSS styles included here -->
<xsl:copy-of select="document('style.xml')/style" />
</head>
<body>
<!-- ... -->
</body>
</html>
</xsl:template>
But this doesn’t solve my problem as it includes the whole .xml file. I only want one of the properties in the xml file to be included so i would have to parse it inside the xsl and include only that node. How do i do that?
Thank you
Update from comments
If I include the following line in my
XSL:<xsl:copy-of select="document('cmsaENV.xml')/STR_ENV_PROPS/text()"/>And my xml contains:
<STR_ENV_PROPS value="c:/apps/cit/deploy/d_cmsadm/cmsa_applicationEnv.xml"/>Then the string
"c:/apps/cit/deploy/d_cmsadm/cmsa_applicationEnv.xm"
will be placed inside my xsl? Is this
correct?
I’m not sure to really get what you want, but if you want to include only the contents of the
<style>element (and not the element itself), replacewith
text()selects the textual content of thestyleelement in the imported document.EDIT: if instead of the textual contents you want the value of an attribute, you need something like:
Note that you need to convert the attribute into a regular text string, which I do with the
string()function.