[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Conditional merge of 2 XML files
Hello,
I knew that it was something linked to recursive templates, i saw some examples in: http://www.dpawson.co.uk/xsl/sect2/merge.html#d6458e19 but i'm unfortunately unable to understand them then unable to adapt them to my problem ... Yes, sorry, i omitted to say these important details. Yes, you were right, the order is important then in your first example, the output expected would be: A B D F G. Knowing that in each files the node values are ordered already. Meaning that having in a file something like : A D G F will not be possible. Regarding the hierarchie, for the two examples you gave me, the two examples will give the same result: A B C D E F. I think that it's better if i give you my concrete files: My first file would be like that file_1.xml: <?xml version="1.0"?> <testCampaignResults> <xcrdApi> <xcrdApiTitle>XCRD Entry Points</xcrdApiTitle> <api> <apiName result="OK">GetVer</apiName> <testFamily> <familyName result="OK">GetVer_Nom</familyName> <testNum> <num result="OK">GetVer_Nom_T1</num> <case result="OK">GetVer_Nom_T1_C1</case> <case result="OK">GetVer_Nom_T1_C3</case> </testNum> </testFamily> <testFamily> <familyName result="OK">GetVer_Str</familyName> <testNum> <num result="OK">GetVer_Str_T1</num> <case result="OK">GetVer_Str_T1_C1</case> </testNum> </testFamily> </api> </xcrdApi> </testCampaignResults> and my second file would be like that, file_2.xml: <?xml version="1.0"?> <testCampaignResults> <xcrdApi> <xcrdApiTitle>XCRD Entry Points</xcrdApiTitle> <api> <apiName>GetVer</apiName> <testFamily> <familyName>GetVer_Nom</familyName> <testNum> <num>GetVer_Nom_T1</num> <case>GetVer_Nom_T1_C1</case> <case>GetVer_Nom_T1_C2</case> <case>GetVer_Nom_T1_C3</case> </testNum> </testFamily> <testFamily> <familyName>GetVer_Str</familyName> <testNum> <num>GetVer_Str_T1</num> <case>GetVer_Str_T1_C1</case> <case>GetVer_Str_T1_C2</case> </testNum> </testFamily> </api> <api> <apiName>GetID</apiName> <testFamily> <familyName>GetID_Nom</familyName> <testNum> <num>GetID_Nom_T1</num> <case>GetID_Nom_T1_C1</case> <case>GetID_Nom_T1_C2</case> <case>GetID_Nom_T1_C3</case> </testNum> </testFamily> </api> </xcrdApi> </testCampaignResults> Then the resulting file should be: result.xml: <?xml version="1.0"?> <testCampaignResults> <xcrdApi> <xcrdApiTitle>XCRD Entry Points</xcrdApiTitle> <api> <apiName result="OK">GetVer</apiName> <testFamily> <familyName result="OK">GetVer_Nom</familyName> <testNum> <num result="OK">GetVer_Nom_T1</num> <case result="OK">GetVer_Nom_T1_C1</case> <case>GetVer_Nom_T1_C2</case> <case result="OK">GetVer_Nom_T1_C3</case> </testNum> </testFamily> <testFamily> <familyName result="OK">GetVer_Str</familyName> <testNum> <num result="OK">GetVer_Str_T1</num> <case result="OK">GetVer_Str_T1_C1</case> <case>GetVer_Str_T1_C2</case> </testNum> </testFamily> </api> <api> <apiName>GetID</apiName> <testFamily> <familyName>GetID_Nom</familyName> <testNum> <num>GetID_Nom_T1</num> <case>GetID_Nom_T1_C1</case> <case>GetID_Nom_T1_C2</case> <case>GetID_Nom_T1_C3</case> </testNum> </testFamily> </api> </xcrdApi> </testCampaignResults> Where file_1.xml are the logs generated by a test campaign and file_2.xml are the reference logs generated thanks to a test plan. The aim of doing this is to show all the tests that have been defined by the test plan but that we forgot to implement and then that don't appear in the logs. The alphabetical order is kept and the hierarchy is kept as well. If by hierarchy you mean that for example "GetVer_Str_T1_C2" cannot be under "GetVer_Nom" then yes i need to keep the hierarchy of my tree. I hope i gave you all the elements needed. I will be greatful if somebody can help me, i found a solution without recursive template (more like a C code) but it's not giving the expected result and dont keep the order. Thanks again. Thomas ********************************* * Thomas Tarpin-Lyonnet * * http://jaccal.sourceforge.net * ********************************* Quoting Michael Kay <mike@xxxxxxxxxxxx>: Unfortunately, for a newcomer to the language, you've selected a rather difficult problem. I'm not sure I even understand the problem fully, for example I don't understand whether the order of elements in the two files is important: I get the impression that it is. This leads to all sorts of questions, for example if the sequence in the first file is
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|