Forum Discussion

tadudek's avatar
tadudek
Occasional Contributor
5 years ago

GroovyUtils XMLHolder throwing Xpath syntax error when XML node value contains escaped character.

GroovyUtils throwing error when XML node value contains escaped characters. 

 

In my script, I'm accessing a node that contains the description of an error. That node when read by my XMLHolder throws this error: 

 

  • Caused by: java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 9 on line 2 in {\nInvalid part number}:
  • Unexpected token name "part" beyond end of expression

It appears that the node I'm reading contains the value "\n", and when the holder tries to read it, it throws the error. 

 

How can I read the node, with the escaped value, and not bomb out?

 

 

12 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Can you please show the sample data? Does it has string literal "\n"?
    • tadudek's avatar
      tadudek
      Occasional Contributor

      Here's the output from the log: 

       

      Tue Mar 31 15:45:21 MDT 2020: INFO: <?xml version="1.0" encoding="UTF-8"?>
      <errorDescription xmlns:p="http://www.ournamespace.com">Invalid part number</errorDescription>

      It appears to be a non-printable char. I also just edited the namespace, as not put publish it on the forum.