Subject: [xsl] Identity Transform Grouping Question From: <ethan.kalfus@xxxxxxx> Date: Mon, 18 Oct 2004 13:30:56 -0400 |
Hi Anton, <<I suppose that's why you used msxml:node-set()?>> The Muenchian method technique used in the xslt that I had posted was supplied to me by another person in another forum. After looking into his technique further, I realized that he had used a Microsoft extension to cull a node set (I assume so that he could use preceding-sibling to iterate over the nodes). I prefer to use "generic" xslt for flexibility in use of a parser, but this is not an absolute. I like using the iterative ("for-each") approach that he used, and had rewritten his solution without having to rely on the extension...it seemed to produce similar results, so I would have used it instead if I were able to get the additional grouping level working. <<If you still have problems with this, let me know.>> Unfortunately, I could not get a successful result. The source tree I had supplied with my post was simplified to (besides make it easier for people on the list to read!) illustrate the nature of my problem. When I run your solution against that simplified tree it appears to produce the correct result. However, when I use a slightly more complex source tree (e.g. multiple cities with multiple offices), the result is inconsistent. To be specific, given the latest source tree: <?xml version="1.0" encoding="UTF-8"?> <locations version="1.0"> <divisions> <division id="B"> <regions> <region name="pacific"> <countries> <country name="China"> <offices> <office id="BR5"> <names> <name lang='en'>Branch 5</name> </names> <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/> </office> </offices> </country> </countries> </region> </regions> </division> <division id="A"> <regions> <region name="europe"> <countries> <country name="Germany"> <offices> <office id="BR3"> <names> <name lang='en'>Branch 3</name> </names> <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="BR6"> <names> <name lang='en'>Branch 4</name> </names> <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"> <names> <name lang='en'>AAAAA Branch 4</name> </names> <address> <line>7 Kings Highway</line> <line>London</line> </address> <cities> <city>London</city> </cities> <phone>+44-99-9999 9999</phone> </office> <office id="BR7"> <names> <name lang='en'>Branch 4</name> </names> <address> <line>22 Abbey Lane</line> <line>London</line> </address> <cities> <city>London</city> </cities> <phone>+44-55-555 5555</phone> </office> </offices> </country> </countries> </region> <region name="americas"> <countries> <country name="United States"> <offices> <office id="HO"> <names> <name lang='en'>Home Office</name> </names> <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"> <names> <name lang='en'>Branch 1</name> </names> <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"> <names> <name lang='en'>Canadian Branch</name> </names> <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> ...after running your solution, my result is: <?xml version="1.0" encoding="utf-8"?> <locations version="1.0"> <divisions> <division id="A"> <regions> <region name="americas"> <countries> <country name="Canada"> <cities> <city> <name>Calgary</name> <offices> <office> <names> <name lang="en">Canadian Branch</name> </names> <location id="Branch 2"> <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> </location> </office> </offices> </city> </cities> </country> <country name="United States"> <cities> <city> <name>Miami</name> <offices> <office> <names> <name lang="en">Branch 1</name> </names> <location id="BR1"> <address> <line>999 Main Street</line> <line>Suite 1200</line> <line>Miami, FL 22222</line> </address> <phone>777-7777</phone> </location> </office> <office> <names> <name lang="en">Home Office</name> </names> <location id="HO"> <address> <line>P.O. Box 1234</line> <line>New York, NY 11111</line> </address> <phone>(212) 123-4567</phone> </location> </office> </offices> </city> <city> <name>New York</name> <offices> <office> <names> <name lang="en">Branch 1</name> </names> <location id="BR1"> <address> <line>999 Main Street</line> <line>Suite 1200</line> <line>Miami, FL 22222</line> </address> <phone>777-7777</phone> </location> </office> <office> <names> <name lang="en">Home Office</name> </names> <location id="HO"> <address> <line>P.O. Box 1234</line> <line>New York, NY 11111</line> </address> <phone>(212) 123-4567</phone> </location> </office> </offices> </city> </cities> </country> </countries> </region> <region name="europe"> <countries> <country name="England"> <cities> <city> <name>London</name> <offices> <office> <names> <name lang="en">AAAAA Branch 4</name> </names> <location id="BR5"> <address> <line>7 Kings Highway</line> <line>London</line> </address> <phone>+44-99-9999 9999</phone> </location> </office> <office> <names> <name lang="en">Branch 4</name> </names> <location id="BR6"> <address> <line>26 Abbey Lane</line> <line>London</line> </address> <phone>+44-22-2222 2222</phone> </location> <location id="BR7"> <address> <line>22 Abbey Lane</line> <line>London</line> </address> <phone>+44-55-555 5555</phone> </location> </office> </offices> </city> </cities> </country> <country name="Germany"> <cities> <city> <name>Frankfurt</name> <offices> <office> <names> <name lang="en">Branch 3</name> </names> <location id="BR3"> <address> <line>P.O. Box 1210</line> <line>Frankfurt, Germany</line> </address> <phone>+49-55-5555 5555</phone> </location> </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> <names> <name lang="en">Branch 5</name> </names> <location id="BR5"> <address> <line>China World Tower 1</line> <line>1 Jian Guo Men Wai Avenue</line> <line>Beijing</line> </address> <phone> </phone> </location> </office> </offices> </city> </cities> </country> </countries> </region> </regions> </division> </divisions> </locations> The problem is noticeable by looking at the transformed U.S. cities. Both cities (Miami and New York) have the same <location> children appearing under their respective <city> parent elements. The problem seems to be the grouping done on offices in different cities in the same country. However, for offices in the same city in the same country, the grouping appears to work just fine (see London results). Additionally, it would be great if the <location> elements were further sorted according to their <address> child elements, so that, for example, the London office located at 22 Abbey Lane would precede its sibling office located at 26 Abbey Lane (my post contained this ordering in the data, but I failed to explicitly mention it). I tried inserting <xsl:sort select="address" /> after your <xsl:sort select="names/name[@lang='en']"/>, but it didn't work. Thanks for your diligent assistance! I really appreciate it. 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] Identity Transform Groupi, Anton Triest | Thread | Re: [xsl] Identity Transform Groupi, Anton Triest |
Re: [xsl] ancestor, M. David Peterson | Date | [xsl] Wild Card in Match Statement, Naomi Gronson |
Month |