XInclude and XSchema

T

Tjerk Wolterink

I have an xml document that
conforms to my xschema document.

Now i wanted to use xinclude in my xml document.

But when i want to validate the xml document to the xschema
i get the following error:

--
[Xerces-J 2.7.1] Validating "structure.xml" against
"file:/D:/development/webapps/XCManager/web/WEB-INF/schemas/structure.xsd"
....
Ln 48 Col 70 - cvc-complex-type.2.4.a: Invalid content was found
starting with element 'xi:include'. One of
'{"http://www.wolterinkwebdesign.com/xml/structure":class}' is expected.
--


What should i do?

I want to be able to use the xi:include element anywhere in
my xml document.
Should i change my xschema?
 
H

Henry S. Thompson

Tjerk said:
I have an xml document that conforms to my xschema document.

Now i wanted to use xinclude in my xml document.

But when i want to validate the xml document to the xschema i get
the following error:

I want to be able to use the xi:include element anywhere in my xml
document. Should i change my xschema?

Yeah, this is a real pain. I don't know of a good general solution.

One could imagine writing an XSLT transform which produced a new
XInclude-friendly schema from an ordinary original, but the result
would be O(n^2) in size . . .

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
T

Tjerk Wolterink

Henry said:
Tjerk Wolterink writes:




Yeah, this is a real pain. I don't know of a good general solution.

One could imagine writing an XSLT transform which produced a new
XInclude-friendly schema from an ordinary original, but the result
would be O(n^2) in size . . .

ht

Should'nt the xml schema xinclude elements be first processed before
it is validated against an xschema document??

Does'nt the w3c define how it must be done?

I'm using Xerces 2.7.1, they claim they support xinclude.
 
P

Pascal Sartoretti

Tjerk said:
Should'nt the xml schema xinclude elements be first processed before
it is validated against an xschema document??

Does'nt the w3c define how it must be done?

I re-read the XInclude recommendation, it is not clear to me. The
recommendation talks about including "infosets", which I understand as
the product of an XML Schema validation (right?).

Suppose that file A "xincludes" file B: this would mean that both A and
B are supposed to be validated against their respective XML schemas
first, and then merged. Hence, it would not be allowed to have 2 invalid
files A and B, whose merge however is valid. (I guess the 2 files have
to be at least well formed in order to produce infosets).

The question can be summarized simply as: "do you first Xinclude and
then check schema conformance, or first check schema conformance and
then Xinclude ?"

Pascal
 
T

Tjerk Wolterink

Pascal said:
I re-read the XInclude recommendation, it is not clear to me. The
recommendation talks about including "infosets", which I understand as
the product of an XML Schema validation (right?).

Suppose that file A "xincludes" file B: this would mean that both A and
B are supposed to be validated against their respective XML schemas
first, and then merged. Hence, it would not be allowed to have 2 invalid
files A and B, whose merge however is valid. (I guess the 2 files have
to be at least well formed in order to produce infosets).

The question can be summarized simply as: "do you first Xinclude and
then check schema conformance, or first check schema conformance and
then Xinclude ?"

anyone has an anwser?
 
H

Henry S. Thompson

Infoset is not necessarily post schema-validation infoset. XInclude
and W3C XML Schema are independent RECs, and can and should be
implemented independently.

There is no unique correct ordering of the two -- I might wish to
constrain where xi:include elements may go in my document, so write a
schema which specifies thes and schema-validate first, then XInclude,
or I might only care about the validity of the result, so I XInclude
first, then schema-validate, or I might have _two_ schemas, and do
schema-validate, XInclude, schema-validate.

There are a number of XML Pipelining languages/tools around, to allow
you to specify which operations you want performed in which order.

I don't know if Xerces easily allows you to specify
XInclude-then-schema-validate, which appears to be what the OP wants.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
T

Tjerk Wolterink

Tjerk said:
anyone has an anwser?


i think i found the answer here:
http://www.xml.com/pub/a/2002/07/31/xinclude.html?page=2

CopyPaste:
===
One of the most common questions about XInclude is how inclusion
interacts with validation, XSL transformation, and other processes
that may be applied to an XML document. The short answer is that it
doesn't. XInclusion is not part of any other XML process. It is a
separate step which you may or may not perform when and where it is
useful to you.

For example, consider validation against a schema. A document can be
validated before inclusion, after inclusion, or both. If you validate
the document before the xi:include elements are replaced, then the
schema has to declare the xi:include elements just like it would
declare any other element. If you validate the document after the
xi:include elements are replaced, then the schema has to declare the
replacement elements. Inclusion and validation are separate,
orthogonal processes that can be performed in any order which is
convenient in the local environment.
===
 
T

Tjerk Wolterink

Henry said:
Infoset is not necessarily post schema-validation infoset. XInclude
and W3C XML Schema are independent RECs, and can and should be
implemented independently.

There is no unique correct ordering of the two -- I might wish to
constrain where xi:include elements may go in my document, so write a
schema which specifies thes and schema-validate first, then XInclude,
or I might only care about the validity of the result, so I XInclude
first, then schema-validate, or I might have _two_ schemas, and do
schema-validate, XInclude, schema-validate.

There are a number of XML Pipelining languages/tools around, to allow
you to specify which operations you want performed in which order.

I don't know if Xerces easily allows you to specify
XInclude-then-schema-validate, which appears to be what the OP wants.

Yes that is what i want, i
think is it easily possible with the api,
but my xml editor does not have an option
to xlinclude-then-schema-validate.

too bad.


But.. there is one strange thing:

When i have a document like this:

<?xml version="1.0"?>
<human-interface
xmlns="http://www.wolterinkwebdesign.com/xml/human-interface"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.wolterinkwebdesign.com/xml/human-interface
../schemas/human-interface.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude">

<xi:include href="validation-messages.xml" parse="xml"/>

</human-interface>


Then there is enough information in the document to validate the
document against the schema (./schemas/human-interface.xsd)

But the validator does not know wether it must
xinclude-then-schema-validate
or just start schema-validate right away.

Should'nt w3c define a attribute like
xi:includeBeforeValidate="true"
??

Now i do'nt know how to document is validated with a validator.
( must i really programmatically setup the validator to work right?)
 
P

Pascal Sartoretti

Tjerk said:
i think i found the answer here:
http://www.xml.com/pub/a/2002/07/31/xinclude.html?page=2

CopyPaste:
===
One of the most common questions about XInclude is how inclusion
interacts with validation, XSL transformation, and other processes that
may be applied to an XML document. The short answer is that it doesn't.
XInclusion is not part of any other XML process. It is a separate step
which you may or may not perform when and where it is useful to you.

For example, consider validation against a schema. A document can be
validated before inclusion, after inclusion, or both.

Very good source, thanks (Elliotte Rusty Harold is always a goldmine...).

So it seems that everything is possible, however it would be nice to
have real-world experience or "best practices" to know what works well
(or not!). Can anybody provide such information?

Pascal
 
T

Tjerk Wolterink

Tjerk said:
Yes that is what i want, i
think is it easily possible with the api,
but my xml editor does not have an option
to xlinclude-then-schema-validate.

too bad.


But.. there is one strange thing:

When i have a document like this:

<?xml version="1.0"?>
<human-interface
xmlns="http://www.wolterinkwebdesign.com/xml/human-interface"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.wolterinkwebdesign.com/xml/human-interface
./schemas/human-interface.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude">

<xi:include href="validation-messages.xml" parse="xml"/>

</human-interface>


Then there is enough information in the document to validate the
document against the schema (./schemas/human-interface.xsd)

But the validator does not know wether it must
xinclude-then-schema-validate
or just start schema-validate right away.

Should'nt w3c define a attribute like
xi:includeBeforeValidate="true"
??

Now i do'nt know how to document is validated with a validator.
( must i really programmatically setup the validator to work right?)

anyone??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,849
Latest member
Fira

Latest Threads

Top