XInclude and ID/IDREF validation

Hi, This is a classic problem, probably with a simple solution (or workaround), but I can't locate it. What can I do to get ID/IDREF to work across file boundaries when using XInclude to construct a document with several modules? I have tried setting up a Validation Scenario naming the master document, and when subordinate modules are validated, this appears to be working, inasmuch as I get validation errors for all modules (including the master) when I validate any of them. But IDREF values in attributes fail validation when their corresponding ID values are in other modules. I am figuring that this is either a setting I have failed to make correctly (where should I be looking?), or maybe a limitation of some kind, such as that when XInclude is involved, only attributes named @xml:id are respected (this is a wild guess), not just any attribute declared as type ID in the DTD (which is what I have). Or maybe I will have to consider going back to external parsed entities? I am very reluctant to do this, since the subordinate documents need their own DOCTYPE declarations to pick up entity declarations of their own, and of course these aren't legal in external parsed entities. I know this is/was a bugaboo in the specification of XInclude, but was figuring that in the time since its inception, solutions have emerged.... Thanks for any tips, as always. Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@mulberrytech.com Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Wendell, The XML parser does not process XIncludes. As the XInclude spec says: "Processing of external entities (as with the rest of DTDs) occurs at parse time. XInclude operates on information sets and thus is orthogonal to parsing." ID/IDREF validation occurs at parse time, and therefore cannot take account of XIncluded material. The solutions, I would suggest, is not to abandon Xinclude, but to redefine the ID/IDREF attributes so that they are no longer ID/IDREF types, but a suitable string type, and then implement validation at the application level rather than the relying on the parser to do the validation. Parser level ID/IDREF validation is too limited to be considered a general purpose validation mechanism for references in any case. Mark
-----Original Message----- From: oxygen-user-bounces@oxygenxml.com [mailto:oxygen-user-bounces@oxygenxml.com] On Behalf Of Wendell Piez Sent: July 22, 2010 12:34 PM To: Oxygen User Subject: [oXygen-user] XInclude and ID/IDREF validation
Hi,
This is a classic problem, probably with a simple solution (or workaround), but I can't locate it.
What can I do to get ID/IDREF to work across file boundaries when using XInclude to construct a document with several modules?
I have tried setting up a Validation Scenario naming the master document, and when subordinate modules are validated, this appears to be working, inasmuch as I get validation errors for all modules (including the master) when I validate any of them. But IDREF values in attributes fail validation when their corresponding ID values are in other modules.
I am figuring that this is either a setting I have failed to make correctly (where should I be looking?), or maybe a limitation of some kind, such as that when XInclude is involved, only attributes named @xml:id are respected (this is a wild guess), not just any attribute declared as type ID in the DTD (which is what I have).
Or maybe I will have to consider going back to external parsed entities? I am very reluctant to do this, since the subordinate documents need their own DOCTYPE declarations to pick up entity declarations of their own, and of course these aren't legal in external parsed entities.
I know this is/was a bugaboo in the specification of XInclude, but was figuring that in the time since its inception, solutions have emerged....
Thanks for any tips, as always.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@mulberrytech.com Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Hi Wendell, When you use XInclude and DTDs the validation is performed on each file as it is (with the XInclude elements not expanded). This is how Xerces works - I opened some time ago a discussion about support for post validation, you can find that here: http://mail-archives.apache.org/mod_mbox/xerces-j-dev/200507.mbox/thread see the "Xinclude with XML Schema versus XInclude with DTD" messages If you use XML Schema or Relax NG or Schematron then the validation will be performed on a document with all the XInclude elements replaced with the included content. A possible solution if you need to stay with DTDs is to move the ID/IDREF constraints from DTDs to a Schematron schema. That needs to be applied only on the main document and as I said above the resolved document will be seen by the Schematron validation. Another solution is to use LIBXML for validation - by default we set the --postvalid option on LIBXML that makes the processor perform the DTD validation after the XInclude processing, thus validating the resolved document against the DTD of the main file. Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 7/22/10 7:33 PM, Wendell Piez wrote:
Hi,
This is a classic problem, probably with a simple solution (or workaround), but I can't locate it.
What can I do to get ID/IDREF to work across file boundaries when using XInclude to construct a document with several modules?
I have tried setting up a Validation Scenario naming the master document, and when subordinate modules are validated, this appears to be working, inasmuch as I get validation errors for all modules (including the master) when I validate any of them. But IDREF values in attributes fail validation when their corresponding ID values are in other modules.
I am figuring that this is either a setting I have failed to make correctly (where should I be looking?), or maybe a limitation of some kind, such as that when XInclude is involved, only attributes named @xml:id are respected (this is a wild guess), not just any attribute declared as type ID in the DTD (which is what I have).
Or maybe I will have to consider going back to external parsed entities? I am very reluctant to do this, since the subordinate documents need their own DOCTYPE declarations to pick up entity declarations of their own, and of course these aren't legal in external parsed entities.
I know this is/was a bugaboo in the specification of XInclude, but was figuring that in the time since its inception, solutions have emerged....
Thanks for any tips, as always.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@mulberrytech.com Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

Dear George, At 04:24 AM 7/23/2010, George Cristian Bina wrote:
When you use XInclude and DTDs the validation is performed on each file as it is (with the XInclude elements not expanded). This is how Xerces works - I opened some time ago a discussion about support for post validation, you can find that here: http://mail-archives.apache.org/mod_mbox/xerces-j-dev/200507.mbox/thread see the "Xinclude with XML Schema versus XInclude with DTD" messages
I'm glad to see the question has come up (as I suspected it would have :-).
If you use XML Schema or Relax NG or Schematron then the validation will be performed on a document with all the XInclude elements replaced with the included content.
Okay.
A possible solution if you need to stay with DTDs is to move the ID/IDREF constraints from DTDs to a Schematron schema. That needs to be applied only on the main document and as I said above the resolved document will be seen by the Schematron validation.
Right: I've considered this, but of course we also want the pull-down menus we get from ID/IDREF.
Another solution is to use LIBXML for validation - by default we set the --postvalid option on LIBXML that makes the processor perform the DTD validation after the XInclude processing, thus validating the resolved document against the DTD of the main file.
Very interesting: we will try this. Hey! It seems to work! Thanks. Thanks! Wendell ====================================================================== Wendell Piez mailto:wapiez@mulberrytech.com Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
participants (3)
-
George Cristian Bina
-
Mark Baker
-
Wendell Piez