[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] How to transform multiple XML docs with XSLT 2.0 into single doc
Subject: Re: [xsl] How to transform multiple XML docs with XSLT 2.0 into single doc From: Jack Bush <netbeansfan@xxxxxxxxxxxx> Date: Fri, 25 Jun 2010 07:17:33 -0700 (PDT) |
Hi All, B Thank youB to all your valuable suggestions but I am still not completely clear on how to apply document() function to query node-set from secondary documents using XPath just yet, even though the concept is simple enough. Let's look at an example found on http://www.ibm.com/developerworks/xml/library/x-tipcombxslt/ with the following documents: cListing 1. geneva.xml -- an XML description of a photo <?xml version="1.0"?> <ph:photo xmlns:ph="http://ananas.org/2003/tips/photo"> B <ph:title>The Jet d'Eau fountain</ph:title> B <ph:location>Geneva</ph:location> B <ph:date>April 2003</ph:date> B <ph:description> B B B The Jet d'Eau fountain is the most recognizable symbol of Geneva. B B B The fountain reaches 140 meters (460 feet) high, roughly the same height B B B as the Embassy Suites hotel in Times Square. B </ph:description> </ph:photo> Listing 2. london.xml -- another XML description of a photo <?xml version="1.0"?> <ph:photo xmlns:ph="http://ananas.org/2003/tips/photo"> B <ph:title>Double-decker bus</ph:title> B <ph:location>London</ph:location> B <ph:date>October 2002</ph:date> B <ph:description> B B B An inescapable symbol of London, the double-decker bus is much taller B B B than typical buses to carry many passengers through the city'sB B B B B overcrowdedB streets. B </ph:description> </ph:photo> Listing 3. index.xml lists the secondary sources <?xml version="1.0"?> <ph:index xmlns:ph="http://ananas.org/2003/tips/photo"> B <ph:title>City sights</ph:title> B B <ph:entry>geneva</ph:entry> B <ph:entry>london</ph:entry> B <ph:entry>paris</ph:entry> B <ph:entry>roma</ph:entry> </ph:index> c Listing 4. merge.xsl -- the stylesheet processes the documents listed in the main source 1<?xml version="1.0"?> 2<xsl:stylesheet version="1.0" 3B B B B B B B B B B B B xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 4B B B B B B B B B B B B xmlns:ph="http://ananas.org/2003/tips/photo"> 5 6 <xsl:output method="html"/> 7 8 <xsl:template match="ph:index"> 9B B <html> 10B B B <head><title><xsl:value-of select="ph:title"/></title></head> 11B B B <xsl:apply-templates/> 12B </html> 13</xsl:template> 14 15<xsl:template match="ph:index/ph:title"> 16B <h1><xsl:apply-templates/></h1> 17</xsl:template> 18 19<xsl:template match="ph:entry"> 20B <img src="{concat(.,'.jpg')}" align="right"/> 21B <xsl:apply-templates select="document(concat(.,'.xml'))"/> 22B <br clear="right"/> 23</xsl:template> 24 25<xsl:template match="ph:photo/ph:title"> 26B <h2><xsl:apply-templates/></h2> 27</xsl:template> 28 29<xsl:template match="ph:location"> 30B <h3>in <xsl:apply-templates/></h3> 31</xsl:template> 32 33<xsl:template match="ph:date"> 34B <p>Date: <xsl:apply-templates/></p> 35</xsl:template> 36 37<xsl:template match="ph:description"> 38B <p><xsl:apply-templates/></p> 39</xsl:template> 40 41</xsl:stylesheet> B I would like the following clarification on the merge.xsl: B ( i ) Is it true that lines 8 - 13 retrieves content of /ph:index/ph:title? If so what is the purpose of lines 15 - 17? ( ii ) What does line 21 do especially the concat() function and which document is it reading from? Is it index.xml? Does it mean that lines 8 - 23 all uses the same document as a result from this line? Likewise, where in this stylesheet that references the secondary source index.xml? ( iii ) Lines 25 - 39 appears to retrieve content of various nodes in the primary source (either geneva.xml orlondon.xml). Exactly which one of them is the primary source document? Or is it able to lookup both at the same time? ( iv ) Lines 25 - 39 all uses ( v ) Lastly, is URI in XSLT is equivalent to filename? e.g. document('geneva.xml') B Again, this area is very new area to me so your patient would be much appreciated. B Thanks, Jack B <xsl:apply-templates/>. Does this statement navigates to the node-set matched within the template only? Or does it also returns the content as well? I thought that only <xsl:value-of select="..."/> could accept the target value being queried. ----- Original Message ---- From: Andriy Gerasika <andriy.gerasika@xxxxxxxxx> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Sent: Wed, 23 June, 2010 5:09:22 AM Subject: Re: [xsl] How to transform multiple XML docs with XSLT 2.0 into single doc > >B B <xsl:template match="/"> >B B B <xsl:for-each select="$data/root/test"> >B B B B B <xsl:for-each select="."/> perhaps here should be xsl:value-of?? >B B B </xsl:for-each> >B B </xsl:template> > </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to transform multiple, Andriy Gerasika | Thread | Re: [xsl] How to transform multiple, Martin Honnen |
Re: [xsl] Beginner Book For XSL/XSL, Nick Leaton | Date | Re: [xsl] How to transform multiple, Martin Honnen |
Month |