Subject: RE: [xsl] Confusion with template! From: "Sumev Kohli" <skohli@xxxxxxxxxxxxxxx> Date: Fri, 21 Sep 2001 23:01:51 -0400 |
Thanks Mike!, As a matter of fact I will like to hear your views on --> I am working on small utility which generates xslt, This xslt is used to convert one xml into another at runtime. I am using xslt on xml schema and mapping info (relationship between both Schema - which is another XML file )to generate another xslt. -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Mike Brown Sent: Friday, September 21, 2001 6:57 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Confusion with template! Sumev wrote: > Hi, > > XSLT --> > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:template match="/"> > <xsl:element name="ADDRESS"> > <xsl:apply-templates/> > </xsl:element> > </xsl:template> Remember: apply-templates = "go process these nodes" (all children by default); template match = "how to process one of these nodes". Based on your input and desired output, I'd say you want, simply, this: <xsl:template match="/"> <xsl:apply-templates select="ADDRESS/RECORD"/> </xsl:template> <xsl:template match="RECORD"> <RECORD ID="{@ID}"> <PALMRECID> <xsl:value-of select="EXCHNGRECID"/> </PALMRECID> <CATEGORYINDEX> <xsl:value-of select="CATEGORY"/> </CATEGORYINDEX> <NAME> <xsl:value-of select="LASTNAME"/> </NAME> <FIRSTNAME> <xsl:value-of select="FIRSTNAME1"/> </FIRSTNAME> </RECORD> </xsl:template> You want to process each RECORD element. Your stylesheets were not doing that.. you were stopping at the ADDRESS element and trying to obtain data by reaching down further into the tree from there. Also: value-of = "create a text node", and if the select identifies a node-set, the text node is created using only the first node in the set. You don't need to use "//" anywhere. This is usually indicative of desperation :) - Mike ____________________________________________________________________________ mike j. brown, fourthought.com | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Confusion with template!, Mike Brown | Thread | Re: [xsl] Confusion with template!, Mike Brown |
Re: [xsl] trouble checking "cousins, Wendell Piez | Date | [xsl] Re: trouble checking "cousins, Yang |
Month |