Subject: [xsl] Re-Organize and Sort Source Tree (Muenchian Method) From: <ethan.kalfus@xxxxxxx> Date: Wed, 29 Sep 2004 13:23:25 -0400 |
I'm struggling with using the Muenchian method to produce a result tree that re-organizes and sorts the source tree's nodes. The goal is to take the source tree and produce a result set that makes the child <cities> element (including its child <city> element) a parent of the <offices> element. The result tree would also be sorted by the following ascending order: division/@id, region/@name, country/@name, new cities/city/name location path, and office/name. I appreciate any assistance with the XSLT. Also, if possible, please include comments describing how the XSLT works, especially if the Muenchian method is used. Thanks very much! Given the following source tree... <?xml version="1.0" encoding="UTF-8"?> <locations> <divisions> <division id="B"> <regions> <region name="pacific"> <countries> <country name="China"> <offices> <office id="BR5"> <name>Branch 5</name> <address> <line>China World Tower 1</line> <line>1 Jian Guo Men Wai Avenue</line> <line>Beijing</line> </address> <cities> <city>Beijing</city> </cities> <phone></phone> </office> </offices> </country> </countries> </region> </regions> </division> <division id="A"> <regions> <region name="europe"> <countries> <country name="Germany"> <offices> <office id="BR3"> <name>Branch 3</name> <address> <line>P.O. Box 1210</line> <line>Frankfurt, Germany</line> </address> <cities> <city>Frankfurt</city> </cities> <phone>+49-55-5555 5555</phone> </office> </offices> </country> <country name="England"> <offices> <office id="BR4"> <name>Branch 4</name> <address> <line>26 Abbey Lane</line> <line>London</line> </address> <cities> <city>London</city> </cities> <phone>+44-22-2222 2222</phone> </office> <office id="BR5"> <name>AAAAA Branch 4</name> <address> <line>7 Kings Highway</line> <line>London</line> </address> <cities> <city>London</city> </cities> <phone>+44-99-9999 9999</phone> </office> </offices> </country> </countries> </region> <region name="americas"> <countries> <country name="United States"> <offices> <office id="HO"> <name>Home Office</name> <address> <line>P.O. Box 1234</line> <line>New York, NY 11111</line> </address> <cities> <city>New York</city> </cities> <phone>(212) 123-4567</phone> </office> <office id="BR1"> <name>Branch 1</name> <address> <line>999 Main Street</line> <line>Suite 1200</line> <line>Miami, FL 22222</line> </address> <cities> <city>Miami</city> </cities> <phone>777-7777</phone> </office> </offices> </country> <country name="Canada"> <offices> <office id="Branch 2"> <name>Canadian Branch</name> <address> <line>1 Prince Edward Boulevard</line> <line>5th Floor</line> <line>Room 10</line> <line>Calgary, Alberta</line> </address> <cities> <city>Calgary</city> </cities> <phone>(888) 888-8888</phone> </office> </offices> </country> </countries> </region> </regions> </division> </divisions> </locations> ...the XSLT would generate the following result tree: <?xml version="1.0" encoding="UTF-8"?> <locations> <divisions> <division id="A"> <regions> <region name="americas"> <countries> <country name="Canada"> <cities> <city> <name>Calgary</name> <offices> <office id="Branch 2"> <name>Canadian Branch</name> <address> <line>1 Prince Edward Boulevard</line> <line>5th Floor</line> <line>Room 10</line> <line>Calgary, Alberta</line> </address> <phone>(888) 888-8888</phone> </office> </offices> </city> </cities> </country> <country name="United States"> <cities> <city> <name>Miami</name> <offices> <office id="BR1"> <name>Branch 1</name> <address> <line>999 Main Street</line> <line>Suite 1200</line> <line>Miami, FL 22222</line> </address> <phone>777-7777</phone> </office> </offices> </city> <city> <name>New York</name> <offices> <office id="HO"> <name>Home Office</name> <address> <line>P.O. Box 1234</line> <line>New York, NY 11111</line> </address> <phone>(212) 123-4567</phone> </office> </offices> </city> </cities> </country> </countries> </region> <region name="europe"> <countries> <country name="England"> <cities> <city> <name>London</name> <offices> <office id="BR5"> <name>AAAAA Branch 5</name> <address> <line>7 Kings Highway</line> <line>London</line> </address> <phone>+44-99-9999 9999</phone> </office> <office id="BR4"> <name>Branch 4</name> <address> <line>26 Abbey Lane</line> <line>London</line> </address> <phone>+44-22-2222 2222</phone> </office> </offices> </city> </cities> </country> <country name="Germany"> <cities> <city> <name>Frankfurt</name> <offices> <office id="BR3"> <name>Branch 3</name> <address> <line>P.O. Box 1210</line> <line>Frankfurt, Germany</line> </address> <phone>+49-55-5555 5555</phone> </office> </offices> </city> </cities> </country> </countries> </region> </regions> </division> <division id="B"> <regions> <region name="pacific"> <countries> <country name="China"> <cities> <city> <name>Beijing</name> <offices> <office id="BR5"> <name>Branch 5</name> <address> <line>China World Tower 1</line> <line>1 Jian Guo Men Wai Avenue</line> <line></line> </address> <phone></phone> </office> </offices> </city> </cities> </country> </countries> </region> </regions> </division> </divisions> </locations> Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] String extraction, Sven Waibel | Thread | Re: [xsl] Re-Organize and Sort Sour, Anton Triest |
Re: [xsl] String extraction, Mukul Gandhi | Date | [xsl] Output escaped characters tha, good all |
Month |