Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » XSD and XPath
XSD and XPath [message #18907] Thu, 01 May 2003 05:50 Go to next message
Eclipse UserFriend
Originally posted by: paechoi.earthlink.net

First of all, my applogies for being ignorant if this has been asked and
discussed before.

When we have a xml schema, e.g., an instance of XMLSchmea, how do
we identify a node in Eclipse/XSD. The simialr approach we have with
XML DOM is done by using the Xalan/XPath API.

Should we use the getDocument() method to get the DOM and use the
Xalan/XPath API. And put it back with setDocument() method? Is there
any other recommending practices in Eclipse/XSD? Thanks

Any comments?


Pae
Re: XSD and XPath [message #18973 is a reply to message #18907] Thu, 01 May 2003 10:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Pae,

I'm not sure what you mean by "identify a node". If you mean that
literally, then xsdSchema.getDocument() gives you the root of all the nodes,
xsdConcreteComponent.getElement() gives you the node associated with a given
component, and xsdSchema.getCorrespondingComponent gives you the component
corresponding to a node. If you really want to identify a component, the
method org.eclipse.emf.ecore.util.EcoreUtil.getURI will give you a URI that
identifies a component and
org.eclipse.emf.ecore.resource.ResourceSet.getEObject will return the
component corresponding to that URI.

I'm also not sure what you mean by "put it back with setDocument". The
document is "permanently" associated with the schema unless you set a new
one; there would be not point in setting the document that's already set.
Note that you should even be able to edit the document and the schema model
will update itself to reflect those changes...


Pae Choi wrote:

> First of all, my applogies for being ignorant if this has been asked and
> discussed before.
>
> When we have a xml schema, e.g., an instance of XMLSchmea, how do
> we identify a node in Eclipse/XSD. The simialr approach we have with
> XML DOM is done by using the Xalan/XPath API.
>
> Should we use the getDocument() method to get the DOM and use the
> Xalan/XPath API. And put it back with setDocument() method? Is there
> any other recommending practices in Eclipse/XSD? Thanks
>
> Any comments?
>
> Pae
Re: XSD and XPath [message #19373 is a reply to message #18973] Fri, 02 May 2003 10:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: paechoi.earthlink.net

My appologies for not beng able to clearly express in the previous
post. I am not sure if I can explain better, but I will try again.

When we have an XML Document,not the XML Schema, as DOM we
can use the XPath API, e.g., Xalan XPath API such as
org.apache.xpath.XPathAPI class by passing a string that represent
the path.

Say we have an XML document(DOM) as follows:

<Patient>
<Age>39</Age>
<Gender>Female</Gender>
<ContactInfo>
<PhoneNumber>123-456-7890</PhoneNumber>
<EmailAddress>patient@somewhere.com</EmailAddress>
</ContactInfo>
</Patient>

And we use the XPath to only get the <ContactInfo>, e.g.,
"//ContactInfo" which should get the result as follows;

<ContactInfo>
<PhoneNumber>123-456-7890</PhoneNumber>
<EmailAddress>patient@somewhere.com</EmailAddress>
</ContactInfo>

I was thinking if there is any similar API in Eclipse like Xalan/XPathAPI
so we can pass the XPath string to locate a node or a list of nodes
without having a reference to a specific node. I am not sure if this make
sense.

At this time, I am thinking to accomplish that by using the DOM so I can
continuously use the Xalan XPathAPI. But I would more than happy to
learn if there is a way to do the same in Eclipse/XSD. Thank you.

Regards,


Pae



"Ed Merks" <merks@ca.ibm.com> wrote in message
news:3EB0FB45.29AA8657@ca.ibm.com...
> Pae,
>
> I'm not sure what you mean by "identify a node". If you mean that
> literally, then xsdSchema.getDocument() gives you the root of all the
nodes,
> xsdConcreteComponent.getElement() gives you the node associated with a
given
> component, and xsdSchema.getCorrespondingComponent gives you the component
> corresponding to a node. If you really want to identify a component, the
> method org.eclipse.emf.ecore.util.EcoreUtil.getURI will give you a URI
that
> identifies a component and
> org.eclipse.emf.ecore.resource.ResourceSet.getEObject will return the
> component corresponding to that URI.
>
> I'm also not sure what you mean by "put it back with setDocument". The
> document is "permanently" associated with the schema unless you set a new
> one; there would be not point in setting the document that's already set.
> Note that you should even be able to edit the document and the schema
model
> will update itself to reflect those changes...
>
>
> Pae Choi wrote:
>
> > First of all, my applogies for being ignorant if this has been asked and
> > discussed before.
> >
> > When we have a xml schema, e.g., an instance of XMLSchmea, how do
> > we identify a node in Eclipse/XSD. The simialr approach we have with
> > XML DOM is done by using the Xalan/XPath API.
> >
> > Should we use the getDocument() method to get the DOM and use the
> > Xalan/XPath API. And put it back with setDocument() method? Is there
> > any other recommending practices in Eclipse/XSD? Thanks
> >
> > Any comments?
> >
> > Pae
>
Re: XSD and XPath [message #19598 is a reply to message #19373] Fri, 02 May 2003 11:57 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Pae,

We have been doing some internal work with EMF to support XPath-like expressions
that can be evaluated directly against EObjects and hence directly against XSD
components, but it still needs much more work and so we have nothing to offer in
this regard right now...

Using XPath against the DOM is currently the only option...


Pae Choi wrote:

> My appologies for not beng able to clearly express in the previous
> post. I am not sure if I can explain better, but I will try again.
>
> When we have an XML Document,not the XML Schema, as DOM we
> can use the XPath API, e.g., Xalan XPath API such as
> org.apache.xpath.XPathAPI class by passing a string that represent
> the path.
>
> Say we have an XML document(DOM) as follows:
>
> <Patient>
> <Age>39</Age>
> <Gender>Female</Gender>
> <ContactInfo>
> <PhoneNumber>123-456-7890</PhoneNumber>
> <EmailAddress>patient@somewhere.com</EmailAddress>
> </ContactInfo>
> </Patient>
>
> And we use the XPath to only get the <ContactInfo>, e.g.,
> "//ContactInfo" which should get the result as follows;
>
> <ContactInfo>
> <PhoneNumber>123-456-7890</PhoneNumber>
> <EmailAddress>patient@somewhere.com</EmailAddress>
> </ContactInfo>
>
> I was thinking if there is any similar API in Eclipse like Xalan/XPathAPI
> so we can pass the XPath string to locate a node or a list of nodes
> without having a reference to a specific node. I am not sure if this make
> sense.
>
> At this time, I am thinking to accomplish that by using the DOM so I can
> continuously use the Xalan XPathAPI. But I would more than happy to
> learn if there is a way to do the same in Eclipse/XSD. Thank you.
>
> Regards,
>
> Pae
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:3EB0FB45.29AA8657@ca.ibm.com...
> > Pae,
> >
> > I'm not sure what you mean by "identify a node". If you mean that
> > literally, then xsdSchema.getDocument() gives you the root of all the
> nodes,
> > xsdConcreteComponent.getElement() gives you the node associated with a
> given
> > component, and xsdSchema.getCorrespondingComponent gives you the component
> > corresponding to a node. If you really want to identify a component, the
> > method org.eclipse.emf.ecore.util.EcoreUtil.getURI will give you a URI
> that
> > identifies a component and
> > org.eclipse.emf.ecore.resource.ResourceSet.getEObject will return the
> > component corresponding to that URI.
> >
> > I'm also not sure what you mean by "put it back with setDocument". The
> > document is "permanently" associated with the schema unless you set a new
> > one; there would be not point in setting the document that's already set.
> > Note that you should even be able to edit the document and the schema
> model
> > will update itself to reflect those changes...
> >
> >
> > Pae Choi wrote:
> >
> > > First of all, my applogies for being ignorant if this has been asked and
> > > discussed before.
> > >
> > > When we have a xml schema, e.g., an instance of XMLSchmea, how do
> > > we identify a node in Eclipse/XSD. The simialr approach we have with
> > > XML DOM is done by using the Xalan/XPath API.
> > >
> > > Should we use the getDocument() method to get the DOM and use the
> > > Xalan/XPath API. And put it back with setDocument() method? Is there
> > > any other recommending practices in Eclipse/XSD? Thanks
> > >
> > > Any comments?
> > >
> > > Pae
> >
Re: XSD and XPath [message #568253 is a reply to message #18907] Thu, 01 May 2003 10:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Pae,

I'm not sure what you mean by "identify a node". If you mean that
literally, then xsdSchema.getDocument() gives you the root of all the nodes,
xsdConcreteComponent.getElement() gives you the node associated with a given
component, and xsdSchema.getCorrespondingComponent gives you the component
corresponding to a node. If you really want to identify a component, the
method org.eclipse.emf.ecore.util.EcoreUtil.getURI will give you a URI that
identifies a component and
org.eclipse.emf.ecore.resource.ResourceSet.getEObject will return the
component corresponding to that URI.

I'm also not sure what you mean by "put it back with setDocument". The
document is "permanently" associated with the schema unless you set a new
one; there would be not point in setting the document that's already set.
Note that you should even be able to edit the document and the schema model
will update itself to reflect those changes...


Pae Choi wrote:

> First of all, my applogies for being ignorant if this has been asked and
> discussed before.
>
> When we have a xml schema, e.g., an instance of XMLSchmea, how do
> we identify a node in Eclipse/XSD. The simialr approach we have with
> XML DOM is done by using the Xalan/XPath API.
>
> Should we use the getDocument() method to get the DOM and use the
> Xalan/XPath API. And put it back with setDocument() method? Is there
> any other recommending practices in Eclipse/XSD? Thanks
>
> Any comments?
>
> Pae


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD and XPath [message #568801 is a reply to message #18973] Fri, 02 May 2003 10:11 Go to previous message
Eclipse UserFriend
Originally posted by: paechoi.earthlink.net

My appologies for not beng able to clearly express in the previous
post. I am not sure if I can explain better, but I will try again.

When we have an XML Document,not the XML Schema, as DOM we
can use the XPath API, e.g., Xalan XPath API such as
org.apache.xpath.XPathAPI class by passing a string that represent
the path.

Say we have an XML document(DOM) as follows:

<Patient>
<Age>39</Age>
<Gender>Female</Gender>
<ContactInfo>
<PhoneNumber>123-456-7890</PhoneNumber>
<EmailAddress>patient@somewhere.com</EmailAddress>
</ContactInfo>
</Patient>

And we use the XPath to only get the <ContactInfo>, e.g.,
"//ContactInfo" which should get the result as follows;

<ContactInfo>
<PhoneNumber>123-456-7890</PhoneNumber>
<EmailAddress>patient@somewhere.com</EmailAddress>
</ContactInfo>

I was thinking if there is any similar API in Eclipse like Xalan/XPathAPI
so we can pass the XPath string to locate a node or a list of nodes
without having a reference to a specific node. I am not sure if this make
sense.

At this time, I am thinking to accomplish that by using the DOM so I can
continuously use the Xalan XPathAPI. But I would more than happy to
learn if there is a way to do the same in Eclipse/XSD. Thank you.

Regards,


Pae



"Ed Merks" <merks@ca.ibm.com> wrote in message
news:3EB0FB45.29AA8657@ca.ibm.com...
> Pae,
>
> I'm not sure what you mean by "identify a node". If you mean that
> literally, then xsdSchema.getDocument() gives you the root of all the
nodes,
> xsdConcreteComponent.getElement() gives you the node associated with a
given
> component, and xsdSchema.getCorrespondingComponent gives you the component
> corresponding to a node. If you really want to identify a component, the
> method org.eclipse.emf.ecore.util.EcoreUtil.getURI will give you a URI
that
> identifies a component and
> org.eclipse.emf.ecore.resource.ResourceSet.getEObject will return the
> component corresponding to that URI.
>
> I'm also not sure what you mean by "put it back with setDocument". The
> document is "permanently" associated with the schema unless you set a new
> one; there would be not point in setting the document that's already set.
> Note that you should even be able to edit the document and the schema
model
> will update itself to reflect those changes...
>
>
> Pae Choi wrote:
>
> > First of all, my applogies for being ignorant if this has been asked and
> > discussed before.
> >
> > When we have a xml schema, e.g., an instance of XMLSchmea, how do
> > we identify a node in Eclipse/XSD. The simialr approach we have with
> > XML DOM is done by using the Xalan/XPath API.
> >
> > Should we use the getDocument() method to get the DOM and use the
> > Xalan/XPath API. And put it back with setDocument() method? Is there
> > any other recommending practices in Eclipse/XSD? Thanks
> >
> > Any comments?
> >
> > Pae
>
Re: XSD and XPath [message #568981 is a reply to message #19373] Fri, 02 May 2003 11:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Pae,

We have been doing some internal work with EMF to support XPath-like expressions
that can be evaluated directly against EObjects and hence directly against XSD
components, but it still needs much more work and so we have nothing to offer in
this regard right now...

Using XPath against the DOM is currently the only option...


Pae Choi wrote:

> My appologies for not beng able to clearly express in the previous
> post. I am not sure if I can explain better, but I will try again.
>
> When we have an XML Document,not the XML Schema, as DOM we
> can use the XPath API, e.g., Xalan XPath API such as
> org.apache.xpath.XPathAPI class by passing a string that represent
> the path.
>
> Say we have an XML document(DOM) as follows:
>
> <Patient>
> <Age>39</Age>
> <Gender>Female</Gender>
> <ContactInfo>
> <PhoneNumber>123-456-7890</PhoneNumber>
> <EmailAddress>patient@somewhere.com</EmailAddress>
> </ContactInfo>
> </Patient>
>
> And we use the XPath to only get the <ContactInfo>, e.g.,
> "//ContactInfo" which should get the result as follows;
>
> <ContactInfo>
> <PhoneNumber>123-456-7890</PhoneNumber>
> <EmailAddress>patient@somewhere.com</EmailAddress>
> </ContactInfo>
>
> I was thinking if there is any similar API in Eclipse like Xalan/XPathAPI
> so we can pass the XPath string to locate a node or a list of nodes
> without having a reference to a specific node. I am not sure if this make
> sense.
>
> At this time, I am thinking to accomplish that by using the DOM so I can
> continuously use the Xalan XPathAPI. But I would more than happy to
> learn if there is a way to do the same in Eclipse/XSD. Thank you.
>
> Regards,
>
> Pae
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:3EB0FB45.29AA8657@ca.ibm.com...
> > Pae,
> >
> > I'm not sure what you mean by "identify a node". If you mean that
> > literally, then xsdSchema.getDocument() gives you the root of all the
> nodes,
> > xsdConcreteComponent.getElement() gives you the node associated with a
> given
> > component, and xsdSchema.getCorrespondingComponent gives you the component
> > corresponding to a node. If you really want to identify a component, the
> > method org.eclipse.emf.ecore.util.EcoreUtil.getURI will give you a URI
> that
> > identifies a component and
> > org.eclipse.emf.ecore.resource.ResourceSet.getEObject will return the
> > component corresponding to that URI.
> >
> > I'm also not sure what you mean by "put it back with setDocument". The
> > document is "permanently" associated with the schema unless you set a new
> > one; there would be not point in setting the document that's already set.
> > Note that you should even be able to edit the document and the schema
> model
> > will update itself to reflect those changes...
> >
> >
> > Pae Choi wrote:
> >
> > > First of all, my applogies for being ignorant if this has been asked and
> > > discussed before.
> > >
> > > When we have a xml schema, e.g., an instance of XMLSchmea, how do
> > > we identify a node in Eclipse/XSD. The simialr approach we have with
> > > XML DOM is done by using the Xalan/XPath API.
> > >
> > > Should we use the getDocument() method to get the DOM and use the
> > > Xalan/XPath API. And put it back with setDocument() method? Is there
> > > any other recommending practices in Eclipse/XSD? Thanks
> > >
> > > Any comments?
> > >
> > > Pae
> >


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XSD v1.0.2 -- Undesired Messages
Next Topic:XSD v1.0.2 -- Undesired Messages
Goto Forum:
  


Current Time: Fri Apr 19 21:17:59 GMT 2024

Powered by FUDForum. Page generated in 0.02779 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top