XSLT Going up a level from current node.
Forgive me if this question sounds easy, but I am not all the way through my XSLT 2.0 book yet (actually only on chapter 3 style sheet structure).
I have the following:
Input (xml doc):
<CPIMessage key="EPO" version="1.0" xmlns="http://www.openfox.com" xmlns:n-pro="http://cjis.fbi.gov/ncic/protectionorder/1.0.0" xmlns:ncic="http://cjis.fbi.gov/ncic/1.0.0" xmlns:cjis="http://cjis.fbi.gov/1.0.0" xmlns:jxdm="http://www.it.ojp.gov/jxdm/3.0.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openfox.com por.xsd">
<Header>
<Initiator>INISP00C2</Initiator>
<Destination>IDACS</Destination>
<ControlField>TESTPOR004</ControlField>
</Header>
Portion of Style sheet
<xsl:template match="cpi:Header">
<xsl:element name="HDR">
<xsl:element name="MKE">
<xsl:value-of select="$key"/>
</xsl:element>
<xsl:element name="ORI">
<xsl:value-of select="cpi:Initiator"/>
</xsl:element>
<xsl:for-each select="cpi:Destination">
<xsl:element name="DST">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<xsl:element name="CTL">
<xsl:value-of select="cpi:ControlField"/>
</xsl:element>
</xsl:element>
</xsl:template>
My output
<HDR><MKE/><ORI>INISP00C2</ORI><DST>IDACS</DST><CTL>TESTPOR004</CTL></HDR>
My Problem I am trying to get the MKE element of the CPIMessage tag.
I was unsure of what to do you can see from the above code on what I tried. I wasn't sure if there is a way to go up to the root node from the current context node. All of the other output works great, I just can't get the data for the mke.
Thanks for your time.
|