Re: p:rename problem

Hi Nic,

The mistake you made is an easy one to make, even for experienced
xprocers.  When you use p:with-option, the processor interprets the
contents of the @select attribute as an xpath expression, and tries to
evaluate it against the current context.  So, since you are intending
the contents of @select to be a string and not an xpath expression,
you should place them in additional quotes to make the expression a
string literal:

<p:rename name='new-identifiers'
xmlns:corbas="http://www.corbas.net/ns/functions">
       <p:with-option name="match" select="'@corbas:id'"/>
       <p:with-option name="new-name" select="'xml:id'"/>
   </p:rename>

Alternatively, you could could use the shortcut form and declare the
match and new-name options as attributes directly on p:rename:

<p:rename name='new-identifiers'
xmlns:corbas="http://www.corbas.net/ns/functions" match="@corbas:id"
new-name="xml:id" />

In this case, you don't need the double quotes, since the contents of
those attributes are already interpreted as strings.

HTH,

-James


On Sun, May 30, 2010 at 4:00 PM, Nic Gibson <nicg@corbas.net> wrote:
> Evening folks
>
> I'm obviously doing something wrong here but I'm also obviously failing to see what. Could anyone point me in the right direction? I have the following xproc script (actually, the final stage of a much longer script but it exhibits the problem).
>
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
>    xmlns:c="http://www.w3.org/ns/xproc-step"
>    name="reset-identifiers">
>    <p:input port="source"/>
>
>    <p:output port="result">
>        <p:pipe port="result" step="done"/>
>    </p:output>
>
>    <p:rename name='new-identifiers' xmlns:corbas="http://www.corbas.net/ns/functions">
>        <p:with-option name="match" select='@corbas:id'/>
>        <p:with-option name="new-name" select='xml:id'/>
>    </p:rename>
>
>    <p:identity name='done'/>
>
> </p:declare-step>
>
> I have the following xml doc that I'm feeding into the above (again stripped down to the minimum):
>
> <book xmlns="http://docbook.org/ns/docbook"
>    xmlns:xlink="http://www.w3.org/1999/xlink"
>    xmlns:corbas="http://www.corbas.net/ns/functions"
>    version="5.0" corbas:id="ba-9781849662505">
> </book>
>
> calabash dies with the following exception:
>
> nicg@newt:~/Dropbox/Bloomsbury/FinalXMLFilesComplete/% java -cp '/usr/local/share/java/calabash.jar:/usr/local/share/java/saxon9he.jar' com.xmlcalabash.drivers.Main --input source=test.xml --output result=test1xml reset-ids.xpl
> May 30, 2010 9:38:53 PM com.xmlcalabash.util.DefaultXProcMessageListener info
> INFO: Running pipeline reset-identifiers
> May 30, 2010 9:38:53 PM com.xmlcalabash.util.DefaultXProcMessageListener error
> SEVERE: XD0045:XProc error err:XD0045
> May 30, 2010 9:38:53 PM com.xmlcalabash.drivers.Main error
> SEVERE: Unknown error
> May 30, 2010 9:38:53 PM com.xmlcalabash.drivers.Main error
> SEVERE: Underlying exception: java.lang.IllegalArgumentException: net.sf.saxon.trans.XPathException: Invalid QName {}
>
>
> Ermmm. Help?
>
> cheers
>
> nic
>
> --
> Nic Gibson
> Director, Corbas Consulting Ltd
> Editorial and Technical Consultancy and Training
> http://www.corbas.co.uk, +44 (0)7718 906817
>
>
>
>
>
>

Received on Sunday, 30 May 2010 21:31:26 UTC