[XSLT] Can not raise some information from a XML sub-node



Hi everybody,

I have to transform an input XML into an output XML using a XSLT style
sheet.
On the input side, the information is stored into sub-nodes.
On the output side, I need to transform the country codes into country
names and report any transform error.
The only requirement is the error must be reported at the root level
("foo123" will cause the error in my following sample)

In order to do it, I use "template match" instructions.
When I am inside the "<code>foo123<code>" block, I did not find any way
to save the error or to raise it to the output root token.

You know that XSLT variables have only a local scope and can only be
instancied once. So I can not use them to save an error status and use
it later.

The brute-force issue would be to prune all the XML tree at the end of
the processus only to check for errors and then report them at the root
level but I am sure there is a better way to do it.


Can anyone help me ?


Thanks in advance.


----- XML samples -----

In the following sample, the error is due to "foo123" which is not a
country code.

* INPUT XML *

<root>
<group>
<country>
<code>44</code>
</country>
<country>
<code>33<code>
</country>
<country>
<code>foo123<code>
</country>
<group>
</root>


* OUTPUT XML *

<root>
<errcode>TRANSFORM_ERROR<errcode>
<countrynames>
<name>ENGLAND</name> <!-- code 44 -->
<name>FRANCE</name> <!-- code 33 -->
</countrynames>
</root>

.



Relevant Pages

  • xsl cdata issue
    ... source contents as itself in the target XML ... My input xml looks like ... How can I achieve this transformation using XSLT? ...
    (comp.text.xml)
  • How to get only first record of the Group
    ... Suppose i have following XML (See Input XML). ... first customer of each record See Output XML? ...
    (microsoft.public.biztalk.general)
  • Re: How to get only first record of the Group
    ... Suppose i have following XML (See Input XML). ... How can I get only the first customer of each record See Output XML? ...
    (microsoft.public.biztalk.general)
  • Re: Illegal Charaters in path
    ... In the sample code I used the LoadXml first and got Data at the root ... Then I tried load, well I ... I have a simple XML ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Trying to parse a HUGE(1gb) xml file
    ... Almost all exmaples pf parsing xml in python, i have seen, start off with these 4 lines of code. ... It's much faster and much more memory friendly than the Python implementation. ... root = tree.getroot#my huge xml has 1 root at the top level ...
    (comp.lang.python)