PARSE XML statement: Error 8312 reason code 3 when trying to parse Unicode variable

So far, I use the PARSE XML statement with binary operands 1 to 4, but I would like to be able to use a dynamic U variable as input.
According to the documentation of the PARSE XML statement, Format U is one of the possible formats for operand 1 (the xml to be parsed), as well as for operands 2-4 (target variables for name, path and value).

However, when I try the statement with a U variable as operand 1, I get an error 8312 reason code 3
(NAT8312 Error during XML parser processing, reason :1:, reason code 3 means “Parser initialization failed”).

What could be the problem?

Thanks very much in advance for your input.
We work with SPoD Nat. 6.3.5 PL 0, and on our remote development environment (AIX),
we have Natural 6.3.8 PL 0.

Kind regards
Eva Grill

Have you tried a non-dynamic U variable?

steve

Another one:

Do U-variables work from a simple Natural program (i.e. outside of the PARSE XML context) ?

@Steve,
yes, I have tried a non-dynamic U variable, with the same result.

@Wolfgang,
yes, we can use U-variables outside of the PARSE XML context, i.e. defining one, assigning values to one, move encoded from or into such a variable.

Kind regards
Eva

I have meanwhile managed to read an xml Unicode file into a dynamic binary variable and
parse it using a dynamic U variable as operand 4 (in below code snippet, named #u-content-dynamic).
Then I use MOVE NORMALIZED on operand 4 and for the following processing use the normalized content
(#u-content-dynamic-n).
When I try to replace #b-dynamic by a U variable, regardless of whether dynamic or not, I get Nat8312 reason code 3 as before.
Presently the coding seems to do what I want, so I could just go on using the binary input and parsing into a unicode variable. I’m however unsure whether this could lead to problems where the input is non-unicode.
Does anyone have experience with this and have a better recommendation?
Thanks in advance for your input.

Eva


READ WORK 1  #b-dynamic  /* XML_PARSER_INPUT
END-WORK
PARSE XML 
  #b-dynamic
   INTO     PATH XML_PARSER_XPATH
   VALUE #u-content-dynamic 
move normalized #u-content-dynamic to #u-content-dynamic-n

DECIDE ON FIRST VALUE OF XML_PARSER_XPATH
...
 VALUE 'message/body/purchase-order/business-partner/street/$'
* using Unicode variables for the original contents
 #street-u := #u-content-dynamic-n      /* using Unicode variables for the contents
*
* selecting the codepage to be used to store the address fields additionally in 1-byte variables,
* e.g. 'ISO-8859-7'  for GReece
   perform get_codepage  /* read from a customizing table; returns #CODEPAGE
   move encoded #u-content-dynamic-n 
        to PURCHASE_ORDER.STREET in codepage  #CODEPAGE
* ...
END-DECIDE
* ...
END-PARSE

In general U variables can be used instead of A variables.

Your kind of problem is located inside the xml document and the understanding of xml processing.

The XML documents most times come along with encoding settings.

If your document has e.g. ISO-8859-7 encoding defined at the XML header and you change the document by read work into a Natural U dynamic, then the document is a UTF-16 document.

Doing this conversion with your data you have to change the encoding setting inside the XML document header, too.

Otherwise the parse statement is mixed up by the encoding setting of the XML document header and the wrong characters found at content of the variable.

Therefore better use B
→ no conversion during read of work file
→ encoding defined inside the XML matches the encoding to the variable content.

Thanks for the explanation, Eric!
Then I’ll keep the binary dynamic variable as operand 1 (the xml to be parsed).