Using collection() with XPath Builder to search across files
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 97
- Joined: Tue Apr 22, 2008 9:31 am
Using collection() with XPath Builder to search across files
Hi
I am trying to use collection() in lieu of a XPath search across all files.
However, I cannot get it to recurse across directories. Do I have the meaning of 'recurse' right? Is recurse files across directories or recurse files within a directory?
For example: the statements:
Does not works:
Works for files in R22:
I want to recurse across all subdirectories of the Samples directory.
I am trying to use collection() in lieu of a XPath search across all files.
However, I cannot get it to recurse across directories. Do I have the meaning of 'recurse' right? Is recurse files across directories or recurse files within a directory?
For example: the statements:
Does not works:
Code: Select all
collection('file:///D:/Develop/IFW MODELLING/Samples?select=*.xml;recurse=true')//postingEntry/name
Code: Select all
collection('file:///D:/Develop/IFW MODELLING/Samples/R22?select=*.xml;recurse=true')//postingEntry/name
-
- Posts: 97
- Joined: Tue Apr 22, 2008 9:31 am
Re: Using collection() with XPath Builder to search across files
I found that the source code does not appear to iterate files across directories:
public Object map(Item item, XPathContext context)
public File[] listFiles()
That is a shame.
public Object map(Item item, XPathContext context)
public File[] listFiles()
That is a shame.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Using collection() with XPath Builder to search across files
Post by sorin_ristache »
Hello,
The correct query parameter is recurse=yes not recurse=true.
Regards,
Sorin
csalsa wrote:However, I cannot get it to recurse across directories. Do I have the meaning of 'recurse' right? Is recurse files across directories or recurse files within a directory?
For example: the statements:
Does not works:Code: Select all
collection('file:///D:/Develop/IFW MODELLING/Samples?select=*.xml;recurse=true')//postingEntry/name
The correct query parameter is recurse=yes not recurse=true.
Regards,
Sorin
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Using collection() with XPath Builder to search across files
Post by sorin_ristache »
What source code are you talking about? The collection() function of Saxon 9 iterates a directory collection if you use the correct parameters. There is an example in the User Manual.csalsa wrote:I found that the source code does not appear to iterate files across directories:
public Object map(Item item, XPathContext context)
public File[] listFiles()
That is a shame.
Regards,
Sorin
-
- Posts: 97
- Joined: Tue Apr 22, 2008 9:31 am
Re: Using collection() with XPath Builder to search across files
Hi Sorin
Thanks for the correction of using 'yes/no' instead of 'true/false'. I had made assumptions on the boolean variable that were obviously wrong from the sample you highlighted.
The code that I was referring to was the 'saxonb' » 'net.sf.saxon.functions' whose source code has been put up on the Internet. I obviously did not spend enough time reading the code either.
The reason that I am trying to get 'collection()' to work is that I really want to search with XPath across a set of directories. We have some 7100 XML files across 35 directories. I know an XPath search will take time. But sometimes you just need an XPath search.
Thanks for the correction of using 'yes/no' instead of 'true/false'. I had made assumptions on the boolean variable that were obviously wrong from the sample you highlighted.
The code that I was referring to was the 'saxonb' » 'net.sf.saxon.functions' whose source code has been put up on the Internet. I obviously did not spend enough time reading the code either.
The reason that I am trying to get 'collection()' to work is that I really want to search with XPath across a set of directories. We have some 7100 XML files across 35 directories. I know an XPath search will take time. But sometimes you just need an XPath search.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Using collection() with XPath Builder to search across files
Post by sorin_ristache »
Hello,
Regards,
Sorin
That is Saxon 9 source code. You should ask Saxonica about it.csalsa wrote:The code that I was referring to was the 'saxonb' » 'net.sf.saxon.functions' whose source code has been put up on the Internet. I obviously did not spend enough time reading the code either.
If you use the collection() function in an XPath 2.0 query as in the User Manual example it should work. Oxygen includes Saxon 9 which executes the collection() call.csalsa wrote:The reason that I am trying to get 'collection()' to work is that I really want to search with XPath across a set of directories. We have some 7100 XML files across 35 directories. I know an XPath search will take time. But sometimes you just need an XPath search.
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service