470,833 Members | 1,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

How to value-of in copy-of document to merge ?

SIMPLY VERSION OF THE QUESTION:
XML_TO_COPY.XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xsl_that_copies.xsl"?>
<fruits date="20060621">
<fruit name="orange" />
</fruits>

COPY_RESULT_THAT_IS_INTENDED.XML
orange

XSL_THAT_TRIES_TO_COPY_BUT_DOES_NOT_WORK.XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<!-- ?!: this or something similar -->
<xsl:copy-of select="document('20060618.xml')/fruits/fruit[value-of
select='@name']" />
</xsl:template>
</xsl:stylesheet>

CRYPTIC VERSION OF THE QUESTION:
I have such xml files stored by dates. On user input for a date range,
I intend to merge that many xml files and output their fruit names.

Thanks in advance.

Jun 21 '06 #1
1 969
vo*******@spatiallink.org wrote:
CRYPTIC VERSION OF THE QUESTION:
I have such xml files stored by dates. On user input for a date range,
I intend to merge that many xml files and output their fruit names.


Your simplified example doesn't match your question, unfortunately. But
some components:

1) User input: That's typically either stylesheet parameters given at
time of execution, or an index file which is presented to the stylesheet
as input. Pick one, determine its syntax, and figure out how you're
going to retrieve/generate the names of the files from that data.

2) You'll then have to for-each over the files. Note that you're likely
to wind up with all the files in memory simultaneously; if they're big,
this may not be tenable and you may want to separate the tasks of
extracting and merging the data. (Some XSLT processors have hooks
specifically to help you manage this kind of
scripting-across-multiple-files problem; Xalan does, for example.
Useful, but unfortunately nonportable.)

3) To get the value(s) from each document, you want something like
<xsl:value-of select="document($filename)/fruits/fruit/@name"/>
or, if you want to check the date within the file
<xsl:value-of
select="document(whatever)/fruits[@date=$datevalue]/fruit/@name"/>

That should be enough to get you started.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by gimme_this_gimme_that | last post: by
13 posts views Thread by Josip | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.