wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes XML searching XSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML searching XSL" Watch "XML searching XSL" New topic
Author

XML searching XSL

Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Hi,

<Data>
<person>
<id>1234</id>
<name>asas</name>
</person>
<person>
<id>123</id>
<name>erwe</name>
</person>
<person>
<id>12</id>
<name>ndfkj</name>
</person>
<person>
<id>1</id>
<name>bdk</name>
</person>
</Data>
-----------XSL----------
<xsl:when test="normalize-space(document('Data.xml.xml')/Data/Person/id)='12')">
<h2><xsl:value-of select="document('Data.xml.xml')/Data/Person/name"/> </h3>
</xsl:when>

I'm trying to search a xml document for id=12 and then display the corresponding name value.
This is not working for me.Please note that my xml file is very large,os it should terminate upon finding the data.
Please tell me how to do it.


Spritle Software Blogs
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
<xsl:value-of select="document('bool12.xml')/Data/person/name[../id='12']"/>
will do it. But you should check how your XSLT processor implements document() function. Most XSLT processors are DOM-based, it may happen that your file will be read as a whole anyway, regardless of how you implement search. I read that Saxon works with SAX, maybe you will have to use it, if you do not already.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Yes Thanks again.Its worked.
It took app 10secs to pick a name for a specific code,i picked three names in random order.my xml file sixe is 3.5MB.
Haven't tired Saxon.Will try soon.
Thanks.
Balaji.
Originally posted by Mapraputa Is:
<xsl:value-of select="document(
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML searching XSL