xpath 2.0 collection function

Here should go questions about transforming XML with XSLT and FOP.
mstoef
Posts: 20
Joined: Tue May 23, 2006 11:10 pm

xpath 2.0 collection function

Post by mstoef »

I'm trying to run an xpath expression over several files with public identifiers. I have a catalog file for resolving my PIs, but Oxygen apparently doesn't reference it when executing xpath. Is that right? Do I need to change to system IDs
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

In <oXygen/> you can run XSLT 2.0 stylesheets with the Saxon 8 processor (the basic version or the schema aware one). If the URI specified as parameter is the path to a file called the collection catalog the function returns a sequence of nodes corresponding to the documents mapped by the catalog file which for Saxon must have the following structure:

Code: Select all

<collection>
<doc href="doc1.xml"/>
<doc href="doc2.xml"/>
<doc href="doc3.xml"/>
</collection>
the href values are relative to the location of the catalog file. Also the URI can point to a directory instead of a catalog file and can have parameters which specify how to match the files to be included in the collection, for example select (for a file pattern), recurse (recurse subdirectories), etc:

Code: Select all

<xsl:for-each select="collection(concat($pathToXMLDirectory, 
'?select=*.xml;recurse=yes;on-error=warn'))">
...
</xsl:for-each>
If the collection function does not contain the expected documents make sure the paths are specified correctly in the catalog file or the match arguments (select, recurse) correspond to the expected collection.

Regards,
Sorin
mstoef
Posts: 20
Joined: Tue May 23, 2006 11:10 pm

Post by mstoef »

This is not the oasis catalog DTD, to which I was referring (is it?). Can you point me to a spec/DTD for this structure?

thanks.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

The implementation of the collection function is processor dependent. The Saxon 8 implementation requires a catalog with the specified format.

Regards,
Sorin
mstoef
Posts: 20
Joined: Tue May 23, 2006 11:10 pm

Post by mstoef »

Thanks. Unfortunately, I'm still in the same boat, receiving an error that it can't find the dtd referenced in the doctype declaration.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

Is the XML document on which the XPath expression is applied valid ? You can check this with the Validate Document action. If you want to resolve a public ID or system ID with an XML catalog create and add the catalog in Preferences and check that the catalog entries are correct by validating the document. After that an XSLT stylesheet which calls collection(URIofCollectionCatalogFile) will resolve the public ID/system ID of documents contained in the collection correctly using the XML catalog. Starting with version 7.2 the XML catalogs configured in Preferences will be used also for solving public IDs/system IDs when the collection() function is used in the XPath toolbar and XPath Builder view.

Regards,
Sorin
mstoef
Posts: 20
Joined: Tue May 23, 2006 11:10 pm

Post by mstoef »

>> Is the XML document on which the XPath expression is applied valid ?

Yes.

>> If you want to resolve a public ID or system ID with an XML catalog >>create >>and add the catalog in Preferences and check that the catalog entries are correct >>by validating the document.

Already did that.

>>After that an XSLT stylesheet which calls collection(URIofCollectionCatalogFile) will >>resolve the public ID/system ID of documents contained in the collection correctly >>using the XML catalog. Starting with version 7.2 the XML catalogs configured in >>Preferences will be used also for solving public IDs/system IDs when the collection() >>function is used in the XPath toolbar and >>XPath Builder view.

But it doesn't. That's my point. This must be a bug.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

I am not sure what does not work on your computer. Does an XSLT 2.0 transformation in which the collection() function is called not work ? I tested it with an XSLT stylesheet in the latest <oXygen/> release (version 7.1) and it works correctly. I expect it works also in previous versions. Please send us small sample files to support at oxygenxml dot com for the XSLT stylesheet, the input XML source, the collection catalog, the XML catalog used to resolve the public ID and the documents which should be returned by the collection() call.

Does an XPath 2.0 query containing a call to collection() and executed in the XPath toolbar / XPath Builder view not use the XML catalog to resolve a public ID in a document returned by collection() ? We just fixed that and it will be available in the version 7.2.

Regards,
Sorin
mstoef
Posts: 20
Joined: Tue May 23, 2006 11:10 pm

Post by mstoef »

I can't post to public. Give me an email address.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

As I said send the sample files to support at oxygenxml dot com.

Regards,
Sorin
Post Reply