• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML searching XSL

 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic