Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML searching XSL

 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic