wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Getting list of non-xml files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Getting list of non-xml files" Watch "Getting list of non-xml files" New topic
Author

Getting list of non-xml files

tulips phan
Greenhorn

Joined: May 11, 2011
Posts: 5
Hi everyone,

I have a problem when using collection function for getting list of file which is on non-xml format. Please help to give me with another function or any argument with collection function.
Thanks,
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12758
    
    5
What is this "collection function"?

All Java file examination starts with the java.io.File object - are you familiar with that class?

Bill
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Based on your other unrelated post, I am going to take a wild guess... this "collection" function is something in XSLT 2.0? Am I right?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
First a preliminary note to clear some possible mis-interpretation: collection() is an xslt 2.0 xpath function.

Now collection() can be considered as a high-octane version of doc() or document(). With its high-performance, come with its restriction. It can be used to collect sequence of non-xml url as it expects to work with the parsing. Any ill-formedness will result in fatal error.

In order to collect an enumerated list of non-xml text file (like .ini containing name/value pairs or even csv or else...) you have to fall back to using doc() or document(). To make the most analog to the use of catalog (xml) in some implementation used with collection(), you can construct some apparently same catalog xml document and load it with doc() or document(). And then feed the href to some user-defined xsl function (or named template) designed for the specific purpose of parsing it.

For instance, let us make a catalog, say catalog.xml, of the form like this.


You could process the enumerated list of external files like this. (<doc>...</doc> wrapper is just for illustration of no generic necessity; and fn is some arbitrary namespace for user-defined xslt function main().)

With the function fn:main() looking possibly like this. (I make maximum continuity of op's previous thread to make the idea of maximum clarity.)

Then the collection will be loaded and parsed into the particular form desired for the authoring of the resultant xml.
tulips phan
Greenhorn

Joined: May 11, 2011
Posts: 5
g tsuji wrote:First a preliminary note to clear some possible mis-interpretation: collection() is an xslt 2.0 xpath function.

Now collection() can be considered as a high-octane version of doc() or document(). With its high-performance, come with its restriction. It can be used to collect sequence of non-xml url as it expects to work with the parsing. Any ill-formedness will result in fatal error.

In order to collect an enumerated list of non-xml text file (like .ini containing name/value pairs or even csv or else...) you have to fall back to using doc() or document(). To make the most analog to the use of catalog (xml) in some implementation used with collection(), you can construct some apparently same catalog xml document and load it with doc() or document(). And then feed the href to some user-defined xsl function (or named template) designed for the specific purpose of parsing it.

For instance, let us make a catalog, say catalog.xml, of the form like this.


You could process the enumerated list of external files like this. (<doc>...</doc> wrapper is just for illustration of no generic necessity; and fn is some arbitrary namespace for user-defined xslt function main().)

With the function fn:main() looking possibly like this. (I make maximum continuity of op's previous thread to make the idea of maximum clarity.)

Then the collection will be loaded and parsed into the particular form desired for the authoring of the resultant xml.


Hi,
Sorry about implicit question and late reply :)
With the question, I mean I using collection function on XSLT that does not support to read a non-xml format file.
And I'd like to get list of file with a pattern string (ex: *.rpt,...). That means we don't know list of specify file-names which need to be read. So I'm afraid that we cannot using collection function to get nodes in input xml. At the present, I must use a wrapper perl/csh script to get list of file and calling make xml report for-each file :(. Anyone, can give me better solution?

Thank so much,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting list of non-xml files
 
Similar Threads
Problems with container managed transaction
Prototype and script.aculo.us ToC
How to map arraylist containing a list of hashmaps using castor
java.lang.NoSuchMethodError
Missing newline in xml output by using XSLT + SAXON + JAVA