This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I'm trying to generate XML beans using a xsd provided by 3rd party and getting the following error. When I put escape character for '-' then it generates XMLBeans without any error. 3rd party says that their XSD is ok. Can some one please advise me why this is failing and why '-' needs to be escaped?
E:\eFileWorkspace\eFileInterface\xmlBeansCompile>createXMLBeans.bat Compiling eFile schema and building xmlBeanEFI.jar
E:\eFileWorkspace\eFileInterface\xmlBeansCompile>scomp -src .\src -javasource 1.5 -out ..\lib\xmlBeanEFI.jar eFIBatchFile1501.xsd createXMLBeans.xsdconfig E:\eFileWorkspace\eFileInterface\xmlBeansCompile\eFIXMLFile1501.xsd:169:4: error: pattern-regex: The regular expression '([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*\.([a-zA-Z0-9_-])+)+' is malformed: '-' is an invalid character range. Write '\-'. Time to build schema type system: 1.437 seconds BUILD FAILED E:\eFileWorkspace\eFileInterface\xmlBeansCompile>
Well, I am no schema expert and I don't know much about regular expressions, but the first two references I found on the internet about regexes in XML Schema did say that you escape the minus sign by preceding it by a backslash, if you want to match a minus sign.
But looking more closely, the schema specification does say
The - character is a valid character range only at the beginning or end of a positive character group.
And the - character in that regex is indeed at the end of the group. So maybe it is correct and the error message is wrong. That would be unfortunate for you because you would be blocked by a bug in the schema processor. I suppose you could beg your third-party supplier to escape the minus sign anyway; that would still be well-formed and equivalent as far as I can see.
That's my best guess right now, although as I said I am not an expert in these topics.