You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by 98030001 <98...@lums.edu.pk> on 2002/01/23 11:45:39 UTC

HELP: Getting Wierd Result using XPath with Xindice

Hello

I am using XPath with the Xindice api. I have the following XML document:

<Start>

<User>
<LoginName>abc</LoginName>
<Password>qqq</Password>
</User>

<User>
<LoginName>xyz</LoginName>
<Password>ttt</Password>
</User>

</Start>

Now I want to get the password for the LoginName = 'xyz'. 
The XPath I have written is:
  //User[LoginName='xyz']/Password[text()]"

The result I get is:

<Password xmlns:src="http://www.dbxml.org/Query" src:col="/db/abc"
src:key="140b1bac66655440000000eb895b1ba6">ttt</Password>

But what I want is ONLY the password TEXT i.e the value of the password and
NOT the complete node information. What Should I do with the Xpath string so
that the result only gives:   ttt 

Please help me with this as this has hold me now for quite a long time.

Thanx.

Arshad

Integrating the database with a WebApp

Posted by Ryan <so...@hotmail.com>.
Hello, all

I have a question regarding running the server in a webhosting environment.

On my test system, I have Tomcat 4 and Struts, with a variety of xml
libraries, I can run
the database server externally, but in the production environment I can't
count on the admin
opening any ports to let me do as I wish.

Is there a way, programmatically, I could run the database server internally
in my webapp?

Also I am having problems getting the AddressBook example to compile.
I have dbXML-Core-1.0b4.zip installed and the AddressBook example in the
server executes
successfully.




Re: HELP: Getting Wierd Result using XPath with Xindice

Posted by Anders Conrad <ac...@dsl.dk>.
Carsten and Arshad.

Xindice to my best knowledge always delivers an XML Document, so to extract
a text node you will need post-processing or filtering.
Carsten shows two examples of this in java code (The DOM solution should
work as well). Depending on your application environment, you could choose
other methods, e.g. XSL transformation or a simple perl script. But
something will have to be done to the Xindie output.

Best regards
Anders
----- Original Message -----
From: "Carsten Ziegert" <ca...@ik.fh-hannover.de>
To: "Mailing List dbXML" <xi...@xml.apache.org>
Sent: Wednesday, January 23, 2002 12:14 PM
Subject: Re: HELP: Getting Wierd Result using XPath with Xindice


> Hi Arshad,
>
> I use a simple workaround to solve the problem in my environment:
>
> private static String getContent(String r) {
>   int first = r.indexOf(">");
>   first = r.indexOf(">", first+1) + 1;
>   int last = r.lastIndexOf("<");
>   return(r.substring(first, last));
> }
>
>
> Alternatively, you can cast your Resource to XMLResource  and then use
> "getContentAsDOM" instead of "getContent".
> After this, you'll have a Node (org.w3c.dom.Node), and can apply
> "getNodeValue()" which returns a String, but I havn't tried it.
>
> See:
> http://www.dbxml.org/api/org/xmldb/api/modules/XMLResource.html
> http://xml.apache.org/apiDocs/org/w3c/dom/Node.html
>
>
> Hi list, I hope I'm right?
>
> Carsten
>
>
> Am 23.01.2002 11:45 Uhr schrieb "98030001" unter <98...@lums.edu.pk>:
>
> > Hello
> >
> > I am using XPath with the Xindice api. I have the following XML
document:
> >
> > <Start>
> >
> > <User>
> > <LoginName>abc</LoginName>
> > <Password>qqq</Password>
> > </User>
> >
> > <User>
> > <LoginName>xyz</LoginName>
> > <Password>ttt</Password>
> > </User>
> >
> > </Start>
> >
> > Now I want to get the password for the LoginName = 'xyz'.
> > The XPath I have written is:
> > //User[LoginName='xyz']/Password[text()]"
> >
> > The result I get is:
> >
> > <Password xmlns:src="http://www.dbxml.org/Query" src:col="/db/abc"
> > src:key="140b1bac66655440000000eb895b1ba6">ttt</Password>
> >
> > But what I want is ONLY the password TEXT i.e the value of the password
and
> > NOT the complete node information. What Should I do with the Xpath
string so
> > that the result only gives:   ttt
> >
> > Please help me with this as this has hold me now for quite a long time.
> >
> > Thanx.
> >
> > Arshad
> >
>
> --
> Carsten Ziegert
> Fachhochschule Hannover
> FB Informations- und Kommunikationswesen
> Ricklinger Stadtweg 120
> 30459 Hannover
> ++49-511-9296-768
> http://summit-bmt.fh-hannover.de
>
>
>


Re: HELP: Getting Wierd Result using XPath with Xindice

Posted by Carsten Ziegert <ca...@ik.fh-hannover.de>.
Hi Arshad,

I use a simple workaround to solve the problem in my environment:

private static String getContent(String r) {
  int first = r.indexOf(">");
  first = r.indexOf(">", first+1) + 1;
  int last = r.lastIndexOf("<");
  return(r.substring(first, last));
}


Alternatively, you can cast your Resource to XMLResource  and then use
"getContentAsDOM" instead of "getContent".
After this, you'll have a Node (org.w3c.dom.Node), and can apply
"getNodeValue()" which returns a String, but I havn't tried it.

See:
http://www.dbxml.org/api/org/xmldb/api/modules/XMLResource.html
http://xml.apache.org/apiDocs/org/w3c/dom/Node.html


Hi list, I hope I'm right?

Carsten


Am 23.01.2002 11:45 Uhr schrieb "98030001" unter <98...@lums.edu.pk>:

> Hello
> 
> I am using XPath with the Xindice api. I have the following XML document:
> 
> <Start>
> 
> <User>
> <LoginName>abc</LoginName>
> <Password>qqq</Password>
> </User>
> 
> <User>
> <LoginName>xyz</LoginName>
> <Password>ttt</Password>
> </User>
> 
> </Start>
> 
> Now I want to get the password for the LoginName = 'xyz'.
> The XPath I have written is:
> //User[LoginName='xyz']/Password[text()]"
> 
> The result I get is:
> 
> <Password xmlns:src="http://www.dbxml.org/Query" src:col="/db/abc"
> src:key="140b1bac66655440000000eb895b1ba6">ttt</Password>
> 
> But what I want is ONLY the password TEXT i.e the value of the password and
> NOT the complete node information. What Should I do with the Xpath string so
> that the result only gives:   ttt
> 
> Please help me with this as this has hold me now for quite a long time.
> 
> Thanx.
> 
> Arshad
> 

-- 
Carsten Ziegert
Fachhochschule Hannover
FB Informations- und Kommunikationswesen
Ricklinger Stadtweg 120
30459 Hannover
++49-511-9296-768
http://summit-bmt.fh-hannover.de