Valid XML, Valid schema. Where did I go wrong?

I once had a valid doctype and valid XML. I put the first on the second, cntrl-s'd and behold: everything was as it should be. I currently have a valid schema (customizable for my still valid XML). I tried the same tried and true approach - but alas, no success.

I get different errors with each validator used, but still new errors from browsers I post (but it makes sense). So I'm not sure what I should give to be most helpful. Validome says:

Cannot find element declaration 'xs: schema'.

and

The markup in the document following the root element must be well formed.

(but this!)

If it would be helpful to have XML and schema please feel free to ask , I just thought that since they are both valid and long lasting, I would try leaving them in the first place. All I do is put the schema on top of the XML and send it through the validator / browser.

Thank!

+2


source to share


3 answers


@Nona A schema is a well-formed document as well as your copy. If, however, you concatenate them, the result is no longer correct.

If you have:

<xs:schema ...>...</xs:schema>
<myxml ...>...</myxml>

      

this is not valid (no root element)

The reason the DTD approach is different is because the inner subset is definitely allowed to be appended to the root element. So:

<DOCTYPE myxml [
... my DTD ...
]>
<myxml ...>...</myxml>

      

well formed.



Unfortunately, it's not entirely trivial to associate a schema with an instance. You may have to look xsi:schema-location

.

UPDATE Unfortunately, the answer will depend on the software structure you are using. AFAIK there is no way to package a document and schema in such a way that any software will accept and try to validate. This is why schemas are so much more than DTDs.

Here's a simple site where you can submit two documents and check.

Anything other than this may require knowledge of the software. There will be different approaches depending on whether you are using ORACLE, Microsoft, etc. This can be done by calling methods to load the document, load the schema, and then validate or set properties (as can be done in Xerces).

The answer may depend on why you are doing this. If you are sending documents to the schema owner then they will have a validation system. If you need valiadte against some other circuit then you will need to get the circuit software and run that. Are you on MS or Unix / Java?

OPTIONAL UPDATE Suggest What is the best way to validate an XML file against an XSD file? As the saying goes, there is no ultra-simple approach.

+3


source


Just a blow in the dark, but is there an XML Schema namespace prefix declared on the root element? This is xmlns: xs = "http://www.w3.org/2001/XMLSchema". If the namespace prefix is ​​not bound to the namespace name, then the document is invalid.



0


source


If you've made the obvious, you might want to consider the reasons why an xs: schema element declaration cannot be found by the validator.

The second error suggests that an angle bracket is missing somewhere, or that there are some elements that are not nested correctly.

0


source







All Articles