W3C home > Mailing lists > Public > xproc-dev@w3.org > November 2009

string-replace match="Date/text()" replace="Title/text()" not doing what I would have thought.. why?

From: Alex Muir <alex.g.muir@gmail.com>
Date: Wed, 11 Nov 2009 15:43:19 +0000
Message-ID: <88b533b90911110743n7f03ee7ay66dfdc2af5c61ecd@mail.gmail.com>
To: xproc-dev@w3.org
Hi,

I'm just playing with an example of from a great tutorial by Roger Costello
and James Garriss using Calabash and getting a result I don't understand.

Given this xproc:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:c="http://www.w3.org/ns/xproc-step"
                name="myPipeline">

    <p:input port="source">
        <p:document href="BookStore.xml"/>
    </p:input>

    <p:output port="result" />

    <p:for-each>
        <p:iteration-source select="//Book" />
        <p:string-replace match="Date/text()" replace="Title/text()" />
    </p:for-each>
    <p:wrap-sequence wrapper="BookStore" />

</p:declare-step>


And this XML:

<?xml version="1.0"?>
<BookStore>
    <Book>
        <Title>My Life and Times</Title>
        <Author>Paul McCartney</Author>
        <Date>1998</Date>
        <ISBN>1-56592-235-2</ISBN>
        <Publisher>McMillin Publishing</Publisher>
    </Book>
    <Book>
        <Title>Illusions The Adventures of a Reluctant Messiah</Title>
        <Author>Richard Bach</Author>
        <Date>1977</Date>
        <ISBN>0-440-34319-4</ISBN>
        <Publisher>Dell Publishing Co.</Publisher>
    </Book>
    <Book>
        <Title>The First and Last Freedom</Title>
        <Author>J. Krishnamurti</Author>
        <Date>1954</Date>
        <ISBN>0-06-064831-7</ISBN>
        <Publisher>Harper &amp; Row</Publisher>
    </Book>
</BookStore>

I'm getting output

<BookStore>
    <Book>
        <Title>My Life and Times</Title>
        <Author>Paul McCartney</Author>
        <Date/>
        <ISBN>1-56592-235-2</ISBN>
        <Publisher>McMillin Publishing</Publisher>
    </Book>
    <Book>
        <Title>Illusions The Adventures of a Reluctant Messiah</Title>
        <Author>Richard Bach</Author>
        <Date/>
        <ISBN>0-440-34319-4</ISBN>
        <Publisher>Dell Publishing Co.</Publisher>
    </Book>
    <Book>
        <Title>The First and Last Freedom</Title>
        <Author>J. Krishnamurti</Author>
        <Date/>
        <ISBN>0-06-064831-7</ISBN>
        <Publisher>Harper &amp; Row</Publisher>
    </Book>
</BookStore>

I would have thought I would get a <Date> tag with some title text() however
I'm getting the empty <Date/> tags?

Why is that and how can I move the title text into the date element as I'm
trying to do.


Thanks Much

-- 


Alex
https://sites.google.com/a/utg.edu.gm/alex
Received on Wednesday, 11 November 2009 21:16:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 11 November 2009 21:16:32 GMT