You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Asaf Lahav <as...@primagrid.com> on 2006/10/19 15:25:22 UTC

Bind a schema to an XmlObject

I have an xml document which is dynamically built.

It is impossible for me to know what schema the xml document will conform to
until it is entirely built.

 

Is it possible to Parse the xml document into an XmlObject, bind a schema to
it and validate?

If possible, How?

 

Thanks in advance,

Asaf


Ask an XmlObject for it's xpath

Posted by ac...@f2s.com.
Hi

Is there a method I can call on an XmlObject A which happens to be a child of
another XmlObject B that will return an xpath expression, that when used in a
query, relative to XmlObject B, would select the original XmlObject A?

E.g. in a query, you are going from string path to node:

'xpath expression' (on node B) -> 'node A'

I want to go the other way, from node to string path:

'node A' -> 'xpath expression' (on node B)

Note that node A could be an attribute or an element. Node B can be assumed to
be the root of a document.

Thanks

Alex.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Bind a schema to an XmlObject

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Yes, it is possible. Assuming that xmlObject represents the document
that you have built and schemaType the Schema type that you determined
the document conforms to, call
 
XmlObject newObject = xmlObject.changeType(schemaType).
 
Then, call newObject.validate() normally.
 
Notes:
1. newObject is a new object and you can't use the old one anymore
(because in general you may get a different Java impl class) but the
process is efficient, there is no copying/reparsing or anything of the
kind going on
2. you need to make sure that if the object refers to a document
(xmlObject.newCursor().isStartdoc() returns true) then the type also
refers to a document type (schemaType.isDocumentType() also returns
true)
 
Radu

________________________________

From: Asaf Lahav [mailto:asaf.lahav@primagrid.com] 
Sent: Thursday, October 19, 2006 6:25 AM
To: user@xmlbeans.apache.org
Subject: Bind a schema to an XmlObject



I have an xml document which is dynamically built.

It is impossible for me to know what schema the xml document will
conform to until it is entirely built.

 

Is it possible to Parse the xml document into an XmlObject, bind a
schema to it and validate?

If possible, How?

 

Thanks in advance,

Asaf

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.