Subject: RE: [xsl] XSLT2 processing question From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 23 May 2006 13:58:00 +0100 |
You could ask this equally of XSLT 1.0. You haven't defined a template that matches idnr, so your stylesheet behaves as if you had defined <xsl:template match="idnr"> <xsl:apply-templates/> </xsl:template> Look in the spec for "built-in template rules". Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Georg Hohmann [mailto:georg.hohmann@xxxxxxxxx] > Sent: 23 May 2006 13:39 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] XSLT2 processing question > > Hello, > > till today i thought that i was no beginner with xslt anymore > but now i'm not sure about. I thought i knew how xsl > processes data but that was wrong (i guess). I read many > basic informations about the processing structure but i > didn't get right idea what in my thinking is wrong. So i bend > my knees and ask the experts ;-) > > What i got is something like this as the source: > --------------------------------------------------------------------- > <?xml version="1.0" encoding="UTF-8"?> > <customers> > <info>This is data about customers</info> > <person> > <name> > <first>John</first> > <last>Doe</last> > </name> > <idnr>123</idnr> > </person> > <person> > <name> > <first>Tom</first> > <last>Test</last> > </name> > <idnr>456</idnr> > </person> > <person> > <name> > <first>Edna</first> > <last>Example</last> > </name> > <idnr>789</idnr> > </person> > </customers> > --------------------------------------------------------------------- > > My Stylesheet looks like this: > --------------------------------------------------------------------- > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="2.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output name="out" method="xml" version="1.0" encoding="UTF-8" > indent="yes"/> > <xsl:template match="/"> > <xsl:result-document format="out" href="result.xml"> > <adress> > <xsl:apply-templates/> > </adress> > </xsl:result-document> > </xsl:template> > <xsl:template match="//name"> > <firstname> > <xsl:value-of select="first"/> > </firstname> > </xsl:template> > </xsl:stylesheet> > --------------------------------------------------------------------- > > What i *want* to have is this: > --------------------------------------------------------------------- > <?xml version="1.0" encoding="UTF-8"?> > <adress> > <firstname>John<firstname> > <firstname>Tom<firstname> > <firstname>Edna<firstname> > </adress> > --------------------------------------------------------------------- > > But the result i get from my stylesheet is this: > --------------------------------------------------------------------- > <?xml version="1.0" encoding="UTF-8"?> > <adress> > This is data about customers > > <firstname>John</firstname> > 123 > > > <firstname>Tom</firstname> > 456 > > > <firstname>Edna</firstname> > 789 > > </adress> > --------------------------------------------------------------------- > > What am I doing wrong? I thought the stylesheet would do the > following: Go to the root element (match="/"), generate my root > ("adress") and add the results of the following template > (apply-templates). The next template searches for the node "name" > everyware in the source ("//name"), and for each nodes it > finds it appends a node called "firstname" with the value of "first". > > Well, obviously this is not (exactly) what it does. Why are > the values of "info" and "idnr" also in the output? I know > this is an issue about how xslt processes data and it's a > real beginner scenario, so i'm sorry to waste your time with > it. I'm not (only) interested in the right solution to get > the result i want but also for an explanation of where my > thinking is wrong. > > I would be happy if someone could give me a hint ... > > Regards, > G. Hohmann
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSLT2 processing question, Georg Hohmann | Thread | Re: [xsl] XSLT2 processing question, andrew welch |
RE: [xsl] Passing variables into XS, Buchcik, Kasimier | Date | Re: [xsl] XSLT2 processing question, andrew welch |
Month |