You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Eric Murphy <er...@shaw.ca> on 2008/07/21 07:53:34 UTC

Confused on namespaces

Is there any way to query a schema element to find out its declaring
namespace? Also how do you set your namespace declarations when creating a
new XmlDocument? While the declarations are in the schema they don't seem to
be available through any of the XmlBeans objects. I would like to set my
namespaces by getting them out of the schema rather than hard coding them
into the code. 

 

Eric Murphy


RE: Confused on namespaces

Posted by Eric Murphy <er...@shaw.ca>.
Thanks Radu. 

This is what I need. What I am doing is creating a new empty XML document
(could be any XML document) to be used as the data container backing up a
web data collection interface. I want to dynamically access the elements
using XPath queries. So in order to pull up the right elements and
dynamically use their setters, I need to query my XML data store. I need to
declare the native schema namespaces when querying for elements.
 
Thanks
Eric

-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radu.preotiuc-pietro@oracle.com] 
Sent: Tuesday, July 22, 2008 2:39 PM
To: user@xmlbeans.apache.org
Subject: Re: Confused on namespaces

If you have a reference to a SchemaLocalElement/Attribute,
then .getName().getNamespaceURI() should do the trick. This is if you
want to get them "from the Schema". If you have an instance, then
XmlObject.newCursor().getName().getNamespaceURI() gets the
element/attribute uri.

As far as "setting" namespace declarations, you don't need to do that.
XMLBeans will insert namespace declarations as needed when you save your
document. You can then use XmlOptions to set some namespace/prefix
mappings that you'd prefer etc.

Radu

On Sun, 2008-07-20 at 22:53 -0700, Eric Murphy wrote:
> Is there any way to query a schema element to find out its declaring
> namespace? Also how do you set your namespace declarations when
> creating a new XmlDocument? While the declarations are in the schema
> they don't seem to be available through any of the XmlBeans objects. I
> would like to set my namespaces by getting them out of the schema
> rather than hard coding them into the code. 
> 
>  
> 
> Eric Murphy
> 
> 


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


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


Re: Confused on namespaces

Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
If you have a reference to a SchemaLocalElement/Attribute,
then .getName().getNamespaceURI() should do the trick. This is if you
want to get them "from the Schema". If you have an instance, then
XmlObject.newCursor().getName().getNamespaceURI() gets the
element/attribute uri.

As far as "setting" namespace declarations, you don't need to do that.
XMLBeans will insert namespace declarations as needed when you save your
document. You can then use XmlOptions to set some namespace/prefix
mappings that you'd prefer etc.

Radu

On Sun, 2008-07-20 at 22:53 -0700, Eric Murphy wrote:
> Is there any way to query a schema element to find out its declaring
> namespace? Also how do you set your namespace declarations when
> creating a new XmlDocument? While the declarations are in the schema
> they don’t seem to be available through any of the XmlBeans objects. I
> would like to set my namespaces by getting them out of the schema
> rather than hard coding them into the code. 
> 
>  
> 
> Eric Murphy
> 
> 


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