Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 513
  • Last Modified:

validate schema

I have a few schema files that validate except for the very first line:

<?xml version="1.0"?>

Yet this line is in many of the examples of schema files I see on the net.

The error is:
java.io.IOException: Problems occurred:Error on line 4 of document file:foo.xsd: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at org.enhydra.validation.SchemaParser.parseSchema(SchemaParser.java:122)
at org.enhydra.validation.SchemaParser.<init>(SchemaParser.java:57)
at org.enhydra.validation.Validator.<init>(Validator.java:40)
at org.enhydra.validation.Validator.getInstance(Validator.java:68)
at ValidatorTest.main(ValidatorTest.java:20)

What is the problem?

0
jdaues
Asked:
jdaues
1 Solution
 
Wayne BradneyIndependent ConsultantCommented:
jdaues,

The answer would seem to lie here:

>>>> Error on line 4 of document file:foo.xsd
                  ^^^
The <?xml... ?> declaration is not strictly a Processing Instruction, it's Prolog, and MUST appear before any elements in the document (it should really be the first line/character encountered by the parser). Anywhere else in the document, "[xX][mM][lL]" is not allowed as a PI.

My guess is that the parser is seeing other text or blank lines before encountering the Prolog.

See the spec for more info at:

http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd

Regards,
WMB
0
 
jdauesAuthor Commented:
The first 4 lines of the file were:

<!-- bla bla bla bla bla bla bla -->
<!-- bla bla bla bla bla bla bla -->
<!-- bla bla bla bla bla bla bla -->
<?xml version="1.0"?>

By simply placing the version line first, this corrects the problem:

<?xml version="1.0"?>
<!-- bla bla bla bla bla bla bla -->
<!-- bla bla bla bla bla bla bla -->
<!-- bla bla bla bla bla bla bla -->

I guess I was thinking the since the first 3 lines were comments, that it didn't matter.  But it does.

Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now