Validate XML fragment against XML Schema XSD

Hello,

I'm not able to find solution to this problem:

I have XML document (lets say doc.xml) and it's schema (doc.xsd). doc.xml consist of elements (XML fragment) that represents templates, that are to be edited by user in raw form (user edits pure XML - tags, attributes, etc). And after user has made the changes I want to validate this element (XML fragment) against the schema, but I have the schema only for whole document,NOT particular elements of document.

I've tried standard way through JAXP and some other approaches but every time I've run into same problem: API allows me to validate only against the schema, that specifies the root element the same as root element in myXML fragment. In other word if I want to validate XML fragments then I have to have schema file foreach fragment even if I have schema file forwhole document which theXML fragmentare part of.

Have you any idea how to solve this?

Kind regards

goerge

PS: Sorry for my English :)

[1076 byte] By [goerge_goergea] at [2007-11-27 7:33:09]
# 1
To validate an XML document with an XML Schema the root element of the XML document is required to be the root element in the XML Schema.
dvohra09a at 2007-7-12 19:13:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Thanks for response.

> To validate an XML document with an XML Schema the

> root element of the XML document is required to be

> the root element in the XML Schema.

Bad news :(

Is there any way, how to manipulate with the Schema in memory (change the Schema object). The idea is to create schema with certain element as root (root of XML fragment) from the original Schema for whole document. Is this somehow possible?

goerge_goergea at 2007-7-12 19:13:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...