Using collection() with archives
Posted: Wed Sep 01, 2010 6:15 am
I'm working on extracting content from MS Excel 2007 format. Ideally, I should be able to work with the archive directly; I can indeed access content without manually unzipping the Excel file first, so that's a good beginning.
However, I've run into some challenges when trying to dynamically load *.xml files located within the *.xlsm archive.
I don't know ahead of time how many worksheets the Excel workbook might contain, so I need to be able to look through multiple sheets, named internally sheet1.xml, sheet2.xml, ... sheetN.xml. Borrowing the wisdom of others found via Google, it sounds like the collection() function is a good way to leverage xsl:for-each constructs to work with multiple files.
However, attempting to use collection() produces an ArchiveEntryNotFoundException, though I can find nothing wrong with the path.
The problematic XSL:
The error I get:
Is the collection() function simply not capable of handling archives? Have I goofed here somehow? Removing the recurse=yes;on-error=warning portion does not change the outcome.
Any advice appreciated.
Cheers,
-- Eiríkr
However, I've run into some challenges when trying to dynamically load *.xml files located within the *.xlsm archive.
I don't know ahead of time how many worksheets the Excel workbook might contain, so I need to be able to look through multiple sheets, named internally sheet1.xml, sheet2.xml, ... sheetN.xml. Borrowing the wisdom of others found via Google, it sounds like the collection() function is a good way to leverage xsl:for-each constructs to work with multiple files.
However, attempting to use collection() produces an ArchiveEntryNotFoundException, though I can find nothing wrong with the path.
The problematic XSL:
Code: Select all
<xsl:for-each select="for $f in
collection(
concat($BASE_PATH, '!/xl/worksheets/?select=sheet*.xml;recurse=yes;on-error=warning')
)
return $f">
... do something with each file ...
</xsl:for-each>
Code: Select all
SystemID: I:\My Documents\OxygenXMLEditor\Projects\[proj_base]\XL-MT\XL2MT.xsl
Severity: error
Description: de.schlichtherle.io.ArchiveController$ArchiveEntryNotFoundException: I:\My Documents\OxygenXMLEditor\Projects\[proj_base]\XL-MT\Source\Working.xlsm\xl\worksheets (no such file entry) - I:\My Documents\OxygenXMLEditor\Projects\[proj_base]\XL-MT\Source\Working.xlsm\xl\worksheets (no such file entry)
Start location: 62:0
Any advice appreciated.
Cheers,
-- Eiríkr