|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Abstracting XSLT to generate multiple forms for th
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@xxxxxxxxxx - email
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







