You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Ramon F Herrera <ra...@patriot.net> on 2010/04/13 01:53:54 UTC

Looking for a simple, XPath-like way to retrieve values from XML files

Hello,

My current application runs on C++ and has many lines like this:


    Variable["user"]        = xpath_of("//root/creator/user");
    Variable["project"]     = xpath_of("//root/creator/project");
    Variable["projectpath"] = xpath_of("//root/creator/projectpath");
    Variable["title"]       = xpath_of("//root/creator/title");
    Variable["notes"]       = xpath_of("//root/creator/notes");

The LHS is a Map, and the RHS is an XQilla function.

http://xqilla.sourceforge.net

Everything is working fine, but it seems that I will have to port the 
application to Java. I don't expect to have any problem going from 
Xerces-C to Xerces-J.

I need a simple retrieval function, though. Xerces programming is more 
or less equivalent to assembly language.

Can you folks recommend some XPath -or equivalent- implementation that 
runs on Java?

TIA,

-Ramon




---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Looking for a simple, XPath-like way to retrieve values from XML files

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi,

JAXP has an XPath API. It is supported by Xalan and Java 5+. Here's a
reference [1] to the Javadocs.

Thanks.

[1]
http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/xpath/package-summary.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Ramon F Herrera <ra...@patriot.net> wrote on 04/12/2010 07:53:54 PM:

> Hello,
>
> My current application runs on C++ and has many lines like this:
>
>
>     Variable["user"]        = xpath_of("//root/creator/user");
>     Variable["project"]     = xpath_of("//root/creator/project");
>     Variable["projectpath"] = xpath_of("//root/creator/projectpath");
>     Variable["title"]       = xpath_of("//root/creator/title");
>     Variable["notes"]       = xpath_of("//root/creator/notes");
>
> The LHS is a Map, and the RHS is an XQilla function.
>
> http://xqilla.sourceforge.net
>
> Everything is working fine, but it seems that I will have to port the
> application to Java. I don't expect to have any problem going from
> Xerces-C to Xerces-J.
>
> I need a simple retrieval function, though. Xerces programming is more
> or less equivalent to assembly language.
>
> Can you folks recommend some XPath -or equivalent- implementation that
> runs on Java?
>
> TIA,
>
> -Ramon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

RE: Looking for a simple, XPath-like way to retrieve values from XML files

Posted by John Lilley <jl...@datalever.com>.
Really its not very hard to write the equivalent of xpath_of(), given the DOM.  Its probably 20 lines of code or so.  Anyone have this laying about already :)

john

-----Original Message-----
From: Ramon F Herrera [mailto:ramon@patriot.net] 
Sent: Monday, April 12, 2010 5:54 PM
To: c-users@xerces.apache.org
Cc: j-users@xerces.apache.org
Subject: Looking for a simple, XPath-like way to retrieve values from XML files


Hello,

My current application runs on C++ and has many lines like this:


    Variable["user"]        = xpath_of("//root/creator/user");
    Variable["project"]     = xpath_of("//root/creator/project");
    Variable["projectpath"] = xpath_of("//root/creator/projectpath");
    Variable["title"]       = xpath_of("//root/creator/title");
    Variable["notes"]       = xpath_of("//root/creator/notes");

The LHS is a Map, and the RHS is an XQilla function.

http://xqilla.sourceforge.net

Everything is working fine, but it seems that I will have to port the 
application to Java. I don't expect to have any problem going from 
Xerces-C to Xerces-J.

I need a simple retrieval function, though. Xerces programming is more 
or less equivalent to assembly language.

Can you folks recommend some XPath -or equivalent- implementation that 
runs on Java?

TIA,

-Ramon




Re: Looking for a simple, XPath-like way to retrieve values from XML files

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi,

JAXP has an XPath API. It is supported by Xalan and Java 5+. Here's a
reference [1] to the Javadocs.

Thanks.

[1]
http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/xpath/package-summary.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Ramon F Herrera <ra...@patriot.net> wrote on 04/12/2010 07:53:54 PM:

> Hello,
>
> My current application runs on C++ and has many lines like this:
>
>
>     Variable["user"]        = xpath_of("//root/creator/user");
>     Variable["project"]     = xpath_of("//root/creator/project");
>     Variable["projectpath"] = xpath_of("//root/creator/projectpath");
>     Variable["title"]       = xpath_of("//root/creator/title");
>     Variable["notes"]       = xpath_of("//root/creator/notes");
>
> The LHS is a Map, and the RHS is an XQilla function.
>
> http://xqilla.sourceforge.net
>
> Everything is working fine, but it seems that I will have to port the
> application to Java. I don't expect to have any problem going from
> Xerces-C to Xerces-J.
>
> I need a simple retrieval function, though. Xerces programming is more
> or less equivalent to assembly language.
>
> Can you folks recommend some XPath -or equivalent- implementation that
> runs on Java?
>
> TIA,
>
> -Ramon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Looking for a simple, XPath-like way to retrieve values from XML files

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Ramon,

The JAXP XPath API supports XPath 1.0 expressions [1]. Whatever sample
you're looking at is just an *example*. You're certainly not restricted to
only selecting attributes.

Thanks.

[1] http://www.w3.org/TR/xpath/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Ramon F Herrera <ra...@patriot.net> wrote on 04/13/2010 04:59:17 PM:

> Hi Michael (and other participants),
>
> Thanks so much for your recommendation.
>
> I downloaded and am experimenting with JAXP. It indeed seems to be a
> perfect match for my needs. It even comes with a very specific example,
> "XPath Demo" that I intend to use as reference.
>
> http://jaxp.dev.java.net/
>
> However, I am concerned because that code only displays attributes:
>
> /root/creator/@projectpath
>
> I wonder whether I need to modify it (how?) in order to produce other
> items, such as the all-important atomic text values?
>
> TIA,
>
> -Ramon
>
>
> On 4/12/2010 9:20 PM, Michael Glavassevich wrote:
> > Hi,
> >
> > JAXP has an XPath API. It is supported by Xalan and Java 5+. Here's a
> > reference [1] to the Javadocs.
> >
> > Thanks.
> >
> > [1]
> > http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/xpath/
> package-summary.html
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Ramon F Herrera<ra...@patriot.net>  wrote on 04/12/2010 07:53:54 PM:
> >
> >> Hello,
> >>
> >> My current application runs on C++ and has many lines like this:
> >>
> >>
> >>      Variable["user"]        = xpath_of("//root/creator/user");
> >>      Variable["project"]     = xpath_of("//root/creator/project");
> >>      Variable["projectpath"] = xpath_of("//root/creator/projectpath");
> >>      Variable["title"]       = xpath_of("//root/creator/title");
> >>      Variable["notes"]       = xpath_of("//root/creator/notes");
> >>
> >> The LHS is a Map, and the RHS is an XQilla function.
> >>
> >> http://xqilla.sourceforge.net
> >>
> >> Everything is working fine, but it seems that I will have to port the
> >> application to Java. I don't expect to have any problem going from
> >> Xerces-C to Xerces-J.
> >>
> >> I need a simple retrieval function, though. Xerces programming is more
> >> or less equivalent to assembly language.
> >>
> >> Can you folks recommend some XPath -or equivalent- implementation that
> >> runs on Java?
> >>
> >> TIA,
> >>
> >> -Ramon
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> >> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Looking for a simple, XPath-like way to retrieve values from XML files

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Ramon,

The JAXP XPath API supports XPath 1.0 expressions [1]. Whatever sample
you're looking at is just an *example*. You're certainly not restricted to
only selecting attributes.

Thanks.

[1] http://www.w3.org/TR/xpath/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Ramon F Herrera <ra...@patriot.net> wrote on 04/13/2010 04:59:17 PM:

> Hi Michael (and other participants),
>
> Thanks so much for your recommendation.
>
> I downloaded and am experimenting with JAXP. It indeed seems to be a
> perfect match for my needs. It even comes with a very specific example,
> "XPath Demo" that I intend to use as reference.
>
> http://jaxp.dev.java.net/
>
> However, I am concerned because that code only displays attributes:
>
> /root/creator/@projectpath
>
> I wonder whether I need to modify it (how?) in order to produce other
> items, such as the all-important atomic text values?
>
> TIA,
>
> -Ramon
>
>
> On 4/12/2010 9:20 PM, Michael Glavassevich wrote:
> > Hi,
> >
> > JAXP has an XPath API. It is supported by Xalan and Java 5+. Here's a
> > reference [1] to the Javadocs.
> >
> > Thanks.
> >
> > [1]
> > http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/xpath/
> package-summary.html
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Ramon F Herrera<ra...@patriot.net>  wrote on 04/12/2010 07:53:54 PM:
> >
> >> Hello,
> >>
> >> My current application runs on C++ and has many lines like this:
> >>
> >>
> >>      Variable["user"]        = xpath_of("//root/creator/user");
> >>      Variable["project"]     = xpath_of("//root/creator/project");
> >>      Variable["projectpath"] = xpath_of("//root/creator/projectpath");
> >>      Variable["title"]       = xpath_of("//root/creator/title");
> >>      Variable["notes"]       = xpath_of("//root/creator/notes");
> >>
> >> The LHS is a Map, and the RHS is an XQilla function.
> >>
> >> http://xqilla.sourceforge.net
> >>
> >> Everything is working fine, but it seems that I will have to port the
> >> application to Java. I don't expect to have any problem going from
> >> Xerces-C to Xerces-J.
> >>
> >> I need a simple retrieval function, though. Xerces programming is more
> >> or less equivalent to assembly language.
> >>
> >> Can you folks recommend some XPath -or equivalent- implementation that
> >> runs on Java?
> >>
> >> TIA,
> >>
> >> -Ramon
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> >> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Looking for a simple, XPath-like way to retrieve values from XML files

Posted by Ramon F Herrera <ra...@patriot.net>.
Hi Michael (and other participants),

Thanks so much for your recommendation.

I downloaded and am experimenting with JAXP. It indeed seems to be a 
perfect match for my needs. It even comes with a very specific example, 
"XPath Demo" that I intend to use as reference.

http://jaxp.dev.java.net/

However, I am concerned because that code only displays attributes:

/root/creator/@projectpath

I wonder whether I need to modify it (how?) in order to produce other 
items, such as the all-important atomic text values?

TIA,

-Ramon


On 4/12/2010 9:20 PM, Michael Glavassevich wrote:
> Hi,
>
> JAXP has an XPath API. It is supported by Xalan and Java 5+. Here's a
> reference [1] to the Javadocs.
>
> Thanks.
>
> [1]
> http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/xpath/package-summary.html
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Ramon F Herrera<ra...@patriot.net>  wrote on 04/12/2010 07:53:54 PM:
>
>> Hello,
>>
>> My current application runs on C++ and has many lines like this:
>>
>>
>>      Variable["user"]        = xpath_of("//root/creator/user");
>>      Variable["project"]     = xpath_of("//root/creator/project");
>>      Variable["projectpath"] = xpath_of("//root/creator/projectpath");
>>      Variable["title"]       = xpath_of("//root/creator/title");
>>      Variable["notes"]       = xpath_of("//root/creator/notes");
>>
>> The LHS is a Map, and the RHS is an XQilla function.
>>
>> http://xqilla.sourceforge.net
>>
>> Everything is working fine, but it seems that I will have to port the
>> application to Java. I don't expect to have any problem going from
>> Xerces-C to Xerces-J.
>>
>> I need a simple retrieval function, though. Xerces programming is more
>> or less equivalent to assembly language.
>>
>> Can you folks recommend some XPath -or equivalent- implementation that
>> runs on Java?
>>
>> TIA,
>>
>> -Ramon
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-users-help@xerces.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org