Subject: [xsl] Recursively merge (aggregate) and traverse DOM trees (XML files)? From: Laky Tang <tulaky@xxxxxxxxx> Date: Mon, 19 Jun 2006 19:45:42 -0700 (PDT) |
I am trying to recursively merge a tree of XML files and then apply some templates to it. I googled and also searched this mailing list but did not find any help. I hope this is possible using XSLT. Can somebody please point me in the right direction? Here is a sample of the input files and desired output. I tried a sample.xsl (see below)which only goes thru the root file, but need help in making it recursively go thru all the linked files as well. Thanks in advance, Laky, Tang ----------------- sample1.xml : <?xml versionfiltered="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="sample.xsl"?> <a> <b p ="key1" q="2"> xxx </b> <b url = "sample2.xml"></b> <b p ="key10" q ="27">yyyy</b> </a> sample2.xml : <?xml versionfiltered="1.0" encoding="UTF-8"?> <a> <b p ="key4" q="22"> xxx2 </b> <b url = "sample3.xml"></b> <b p ="key7" q ="37">yyyy2</b> <b url = "sample4.xml"></b> </a> sample3.xml : <?xml versionfiltered="1.0" encoding="UTF-8"?> <a> <b p ="key5" q="23"> xxx3 </b> <b p ="key6" q ="26">yyyy3</b> </a> sample4.xml : <?xml versionfiltered="1.0" encoding="UTF-8"?> <a> <b p ="key8" q="24"> xxx4 </b> <b p ="key9" q ="25">yyyy4</b> </a> sample.xsl : <?xml versionfiltered="1.0" encoding="UTF-8"?> <xsl:stylesheet versionfiltered="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" xmlns:xlink="http://www.w3.org/1999/xlink"> <xsl:template match="/"> <html> <head> <title>Sample</title> </head> <h1> <center> </center> </h1> <p/> <xsl:for-each xml:space="default" select="param"> <xsl:value-of select="."/> </xsl:for-each> <table border="2" bgcolor="yellow"> <tr> <th>P</th> <th>Q</th> <th>text</th> </tr> <xsl:for-each select="//b"> <tr> <td> <xsl:value-of select="@p"/> </td> <td> <xsl:value-of select="@q"/> </td> <td> <xsl:value-of select="."/> </td> </tr> </xsl:for-each> </table> </html> </xsl:template> </xsl:stylesheet> Desired output (preferably as a html table): P Q text key1 2 xxx key4 22 Xxx2 key5 23 xxx3 key6 26 yyy3 Key7 37 yyy2 key8 24 xxx4 key9 25 yyy4 key10 27 yyyy __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Value Mapping, omprakash . v | Thread | RE: [xsl] Recursively merge (aggreg, Michael Kay |
[xsl] Value Mapping, oknam park | Date | Re: [xsl] Selecting all nodes betwe, Duncan Anker |
Month |