I suspect you mis-typed the expected output. Based on the example XML, I
surmise that the output you wanted is:
username: eattabasco
and when you change to full_name, the output you expect is:
full_name: Johnathon Wright
as you stated.
This really isn't very complicated. I took your XML and added an enclosing
element to make it well-formed (note; I have studiously excluded the term
"root" in describing this element because it seems that term is defined
differently in XML and XPath and I don't want to wander into that swamp again).
<?xml version="1.0" encoding="UTF-8" ?>
<doc>
<field_definition>
<name>username</name>
<type>text</type>
</field_definition>
<data>
<username>eattabasco</username>
<full_name>Johnathon Wright</full_name>
</data>
</doc>
This stylesheet will produce desired output #1:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:variable name="target" select="/doc/field_definition/name" />
<xsl:template match="doc">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="data">
<xsl:value-of select="$target" />:<xsl:value-of
select="child::node()[local-name()= $target]" />
</xsl:template>
<xsl:template match="field_definition" />
</xsl:stylesheet>
If you change your input XML so:
<name>full_name</name>
you will get the alternate output:
full_name: Johnathon Wright
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--