[xquery-talk] Can XQuery Update corrupt documents?

Joe Wicentowski joewiz at gmail.com
Fri Jun 10 12:54:18 PDT 2016


Hi Ghislain and Mike,

Thank you for your replies, and thanks especially to Mike for tracking down
the source of the problem I was having.  As indicated at
https://saxonica.plan.io/issues/2789, a forthcoming maintenance release of
Saxon will incorporate the fix.

In the meantime, I have a workaround - which has its own drawbacks.
Perhaps this is a pure XQuery question, and isn't Saxon-specific.  Here's
the problem: If I remove the local:reconstruct() function, the XQuery
Update operation works just fine, but all of the resulting interior nodes
have an additional unwanted in-scope namespace declaration - see what
happens to the source after transformation:

Source:
    <note xmlns="http://www.tei-c.org/ns/1.0" xmlns:frus="
http://history.state.gov/frus/ns/1.0">
        For text of NSC 164/1, see
        <ref>
            <hi rend="italic">Foreign Relations,</hi>
            1952–1954, vol. VII, Part 2
        </ref>, p. 1914.
    </note>

After transformation:
    <note xmlns="http://www.tei-c.org/ns/1.0" xmlns:frus="
http://history.state.gov/frus/ns/1.0">
        For text of NSC 164/1, see
        <ref>
            <hi xmlns:frus="http://history.state.gov/frus/ns/1.0"
rend="italic">Foreign Relations,</hi>
            1952–1954, vol. VII, Part 2, p. 1914
        </ref>.
    </note>

See the `xmlns:frus="http://history.state.gov/frus/ns/1.0"` bit?  This
namespace is in scope for the whole document, so I don't want it to
reappear each time I This didn't appear when I used local:reconstruct().  I
couldn't figure out any way to suppress this from appearing, except my
local:reconstruct() function, which triggered the Saxon bug.  I can clean
this extra namespace declaration up via find and replace, but it would be
ideal not to have to do this.

Is there a way to suppress the declaration of in-scope namespaces in the
result?  I've posted a new gist with the updated code to demonstrate the
issue: https://gist.github.com/joewiz/6092b1181cd53d9a5378aed369387bff.

Thanks,
Joe

On Fri, Jun 10, 2016 at 4:49 AM, Ghislain Fourny <g at 28.io> wrote:

> Hi Joe,
>
> I agree with Mike. Also, I noticed that you are declaring your program as
> XQuery 3.0. As far as I know, the XQuery Update 3.0 specification is still
> a Working Draft ( https://www.w3.org/TR/xquery-update-30/ ). I would
> advise proceeding with care if you combine new XQuery 3.0 constructs with
> updates.
>
> Kind regards,
> Ghislain
>
>
> On Fri, Jun 10, 2016 at 10:39 AM, Michael Kay <mike at saxonica.com> wrote:
>
>> I've logged this as a Saxon issue here:
>>
>> https://saxonica.plan.io/issues/2789
>>
>> and you can track progress on it there by registering and doing a "watch"
>> (the icon for that in Redmine is a five-pointed star, as anyone would
>> guess).
>>
>> I'm afraid my first attempts threw up several different symptoms which
>> may or may not turn out to be relevant to the problem that you experienced.
>> As I mentioned, XQuery Update doesn't get exercised very much except for
>> running the limited W3C test suite and a very small batch of unit tests
>> when we make a release.
>>
>> Michael Kay
>> Saxonica
>>
>>
>> On 9 Jun 2016, at 23:53, Joe Wicentowski <joewiz at gmail.com> wrote:
>>
>> Hi all,
>>
>> I'm struggling with an XQuery Update problem which is corrupting the file
>> I'm trying to update.  I've posted my code samples to
>> https://gist.github.com/joewiz/2369367de3babba30e0aad8c9beec893 - but
>> here's the core of the issue:
>>
>> I'm working with a TEI document containing <ref> elements that I'm trying
>> to manipulate with XQuery Update. Specifically, I'm grabbing a page number
>> reference from the text node immediately following the <ref> element, and I
>> want to move the page number inside the <ref> element. (I'm actually trying
>> to do a few more things, but I've reduced the sample code to do just this,
>> because it illustrates the problem I'm facing.)
>>
>> The problem is that the XQuery Update statement corrupts my file. The
>> resulting file has 0 bytes. When I comment out the XQuery Update statement
>> and uncomment the $test variable in the return expression, I get expected
>> results, so I think the logic is sound. I have a feeling that the problem
>> may have to do with line 25, where I add attributes to an element; when I
>> comment out this, the corruption doesn't occur. But I need the attributes
>> in that line. So I'm stumped. I've never encountered data corruption with
>> XQuery Update, so I really hope there's a solution.
>>
>> I'm using Saxon-EE XQuery 9.6.0.7 inside of oXygen 17.1, with Saxon's
>> options for XQuery 3.0 and XQuery Update enabled.
>>
>> Many thanks for any suggestions,
>> Joe
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk
>>
>>
>>
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://x-query.com/pipermail/talk/attachments/20160610/4e610b13/attachment.html>


More information about the talk mailing list