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

Discussion in 'XML' started by volunteer@spatiallink.org, Jun 21, 2006.

  1. Guest

    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:eek:utput 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, 2006
    #1
    1. Advertising

  2. 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
     
    Joe Kesselman, Jun 22, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    486
    Joris Gillis
    Jun 22, 2006
  2. Alex
    Replies:
    2
    Views:
    1,237
  3. Replies:
    26
    Views:
    2,121
    Roland Pibinger
    Sep 1, 2006
  4. lee_j
    Replies:
    6
    Views:
    164
    lee_j
    Nov 27, 2003
Loading...

Share This Page