- From: HILLMAN, Tomos <tomos.hillman@oup.com>
- Date: Mon, 21 Jun 2010 13:39:42 +0100
- To: "xproc-dev@w3.org" <xproc-dev@w3.org>
Hi List, Apologies in advance for lengthy pseudo-code... I've got a bit of funny behaviour happening in xproc (I'm running calabash via oXygen), that I'm hoping someone here might be able to shed some light on. I'm writing a chunking script which pulls out all of the instances of a particular element (let's call it <div>), wraps it in an element (let's call it <doc>) and adds some metadata, so that one of the output files should look something like this: <doc> <meta/> <div/> </doc> Original document might look a bit like this: <book> <chapter> <div/> <div/> </chapter> <chapter> <div/> </chapter <book> and we can assume that everything in it has an @id attribute. All of that works fine. I then want to pull some information out of the original document based on the ancestors in that document of our <div> element - for instance the ancestor::chapter/@id of the div. so here's some pseudocode for my pipeline: _____ <p:input port="source"> <p:document href="original.xml"/> </p:input> <p:output port="result" sequence="true"> <p:identity name="loadDocument"/> <p:identity name="meta> <p:input port="source"> <p:inline> <meta><ancestorID> </ancestorID></meta> </p:inline> </p:input> </p:identity> <p:filter select="//div"> <p:input port="source"> <p:pipe port="result" step="loadDocument"/> </p:input> </p:filter> <p:for-each name="forEachChunk"> <p:variable name="divID" select="/*/@id"/> <p:variable name="ancestorID" select="//div[@id=$divID]/ancestor::chapter[1]/@id"> <p:pipe port=result" step="loadDocument"/> </p:variable> <p:wrap name="wrapChunks" wrapper="doc" match="/*"/> <p:identity name="wrappedChunks"/> <p:identity name="resumeMeta"> <p:input port="source"> <p:pipe port="result" step="meta"/> </p:input> </p:identity> <p:string-replace name="completeMeta" match="//ancestorID/text()" replace="string($ancestorID)"/> <p:insert name="insertMeta" match="/doc" position="first-child"> <p:input port="source"> <p:pipe port="result" step="wrappedChunks"/> </p:input> <p:input port="insertion"> <p:pipe port="result" step="completeMeta"/> </p:input> </p:insert> </p:for-each> _____ The error message I get here is for an undeclared variable in the 'ancestorID' variable step (the undeclared variable being $divID). I've also tried using <p:with-option> to evaluate @replace on the 'completeMeta' string-replace step, but this results in an empty string. I find that particularly weird in that if I then do a count() on the same xpath, it returns the value '1'. Can anyone suggest a way forward? Thanks in advance, Tom Oxford University Press (UK) Disclaimer This message is confidential. You should not copy it or disclose its contents to anyone. You may use and apply the information for the intended purpose only. OUP does not accept legal responsibility for the contents of this message. Any views or opinions presented are those of the author only and not of OUP. If this email has come to you in error, please delete it, along with any attachments. Please note that OUP may intercept incoming and outgoing email communications.
Received on Monday, 21 June 2010 12:40:18 UTC