This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes error creating XMLBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "error creating XMLBeans" Watch "error creating XMLBeans" New topic

error creating XMLBeans

Nazmul Bhuiyan

Joined: May 23, 2002
Posts: 17
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?

Compiling eFile schema and building xmlBeanEFI.jar


E:\eFileWorkspace\eFileInterface\xmlBeansCompile>SET JAVA_HOME="C:\jdk1.5.0_04"

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
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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.

Here's the official specification:

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.
I agree. Here's the link:
subject: error creating XMLBeans
It's not a secret anymore!