[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: combining XML documents
Reading files from a directory might be possible using the
collection() function in XSLT 2.0 or XQuery, but it depends on the
implementation since the mapping of collection URIs to filestore isn't defined
in the spec.
With Saxon you can do something like
<xsl:for-each-group
select="collection('file://c:/some-directory?select=*.xml;recurse=yes')"
group-by="/doc/title">
<xsl:value-of
select="/doc/title"/>
<xsl:value-of
select="count(current-group())"/>
</xsl:for-each-group>
to give you a flavour of what's possible; for a more
specific solution one would need to know more about your
requirements.
As far as the choice between XSLT and XQuery is concerned,
I'm tending to sum it up like this:
(a) if your data is in a database, you need
XQuery
(b) copying a document with small changes is much easier in
XSLT
(c) extracting a small amount of information from your
documents is easier in XQuery
(d) XQuery is easier to learn and is simpler for small
jobs
(e) XQuery is better for highly-structured data, XSLT
for loosely-structured documents
(f) for large applications involving reusable components,
use XSLT
I'd encourage you to learn both, since 80% of what you
learn will be applicable to both languages.
Michael Kay
http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|