From leo.studer at varioweb.ch Wed Jun 1 01:20:18 2016 From: leo.studer at varioweb.ch (Leo Studer) Date: Wed, 1 Jun 2016 10:20:18 +0200 Subject: [xquery-talk] xpath default namespace In-Reply-To: <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> Message-ID: <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> Hi Michael > > > The main difference from the XSLT xpath-default-namespace is that this default applies both to names in path expressions and to names in element constructors, which is inconvenient when the input and output documents are in different namespaces. > > Michael Kay > Saxonica this is exactly my problem. The XML file has no namespace and the output has a namespace. Fist I tried declare namespace null=??; and in the query I wrote something like null:elementName Then I get the error that namespace null is not declared?. The only solution I found is to put a namespace in the XML file (which is not really what I want). Is there another way? Cheers Leo From g at 28.io Wed Jun 1 02:06:35 2016 From: g at 28.io (Ghislain Fourny) Date: Wed, 1 Jun 2016 11:06:35 +0200 Subject: [xquery-talk] xpath default namespace In-Reply-To: <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> Message-ID: Hi Leo, If the input has no namespace, then I think you can declare the default namespace according to your output (if it is important to you that your output uses it as a default namespace). Then there is a workaround to navigate the input with /*:foo/*:bar expressions, where the joker prefix should catch the absence of namespace. I hope it helps? Kind regards, Ghislain On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer wrote: > Hi Michael > > > > > > > The main difference from the XSLT xpath-default-namespace is that this > default applies both to names in path expressions and to names in element > constructors, which is inconvenient when the input and output documents are > in different namespaces. > > > > Michael Kay > > Saxonica > > this is exactly my problem. The XML file has no namespace and the output > has a namespace. > > Fist I tried > > declare namespace null=??; > > and in the query I wrote something like > > null:elementName > > Then I get the error that namespace null is not declared?. > > The only solution I found is to put a namespace in the XML file (which is > not really what I want). > > Is there another way? > > Cheers > Leo > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From leo.studer at varioweb.ch Wed Jun 1 02:38:52 2016 From: leo.studer at varioweb.ch (Leo Studer) Date: Wed, 1 Jun 2016 11:38:52 +0200 Subject: [xquery-talk] xpath default namespace In-Reply-To: References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> Message-ID: <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> Hi Ghislain thank you for your input, which solves my problem. However, if I have the same element name in two different namespaces, then the use of a wildcard namespace makes problems ;-). Always Leo > On 01 Jun 2016, at 11:06, Ghislain Fourny wrote: > > Hi Leo, > > If the input has no namespace, then I think you can declare the default namespace according to your output (if it is important to you that your output uses it as a default namespace). > > Then there is a workaround to navigate the input with /*:foo/*:bar expressions, where the joker prefix should catch the absence of namespace. > > I hope it helps? > > Kind regards, > Ghislain > > > On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer > wrote: > Hi Michael > > > > > > > The main difference from the XSLT xpath-default-namespace is that this default applies both to names in path expressions and to names in element constructors, which is inconvenient when the input and output documents are in different namespaces. > > > > Michael Kay > > Saxonica > > this is exactly my problem. The XML file has no namespace and the output has a namespace. > > Fist I tried > > declare namespace null=??; > > and in the query I wrote something like > > null:elementName > > Then I get the error that namespace null is not declared?. > > The only solution I found is to put a namespace in the XML file (which is not really what I want). > > Is there another way? > > Cheers > Leo > _______________________________________________ > 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: From g at 28.io Wed Jun 1 02:44:24 2016 From: g at 28.io (Ghislain Fourny) Date: Wed, 1 Jun 2016 11:44:24 +0200 Subject: [xquery-talk] xpath default namespace In-Reply-To: <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> Message-ID: Hi Leo, I'm glad! Should this happen, I guess you could add a filter using an XPath function to test for the namespace of the name of the selected element. https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name and https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName You can test for the absence of namespace easily. There may be even shorter tricks, I wouldn't be surprised if Mike got something out of his magic hat :-) Kind regards, Ghislain On Wed, Jun 1, 2016 at 11:38 AM, Leo Studer wrote: > Hi Ghislain > > thank you for your input, which solves my problem. > > However, if I have the same element name in two different namespaces, then > the use of a wildcard namespace makes problems ;-). > > Always > Leo > > On 01 Jun 2016, at 11:06, Ghislain Fourny wrote: > > Hi Leo, > > If the input has no namespace, then I think you can declare the default > namespace according to your output (if it is important to you that your > output uses it as a default namespace). > > Then there is a workaround to navigate the input with /*:foo/*:bar > expressions, where the joker prefix should catch the absence of namespace. > > I hope it helps? > > Kind regards, > Ghislain > > > On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer > wrote: > >> Hi Michael >> >> > >> > >> > The main difference from the XSLT xpath-default-namespace is that this >> default applies both to names in path expressions and to names in element >> constructors, which is inconvenient when the input and output documents are >> in different namespaces. >> > >> > Michael Kay >> > Saxonica >> >> this is exactly my problem. The XML file has no namespace and the output >> has a namespace. >> >> Fist I tried >> >> declare namespace null=??; >> >> and in the query I wrote something like >> >> null:elementName >> >> Then I get the error that namespace null is not declared?. >> >> The only solution I found is to put a namespace in the XML file (which is >> not really what I want). >> >> Is there another way? >> >> Cheers >> Leo >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> > > _______________________________________________ > 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: From mike at saxonica.com Wed Jun 1 04:15:18 2016 From: mike at saxonica.com (Michael Kay) Date: Wed, 1 Jun 2016 12:15:18 +0100 Subject: [xquery-talk] xpath default namespace In-Reply-To: References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> Message-ID: <5EDC98E6-36E5-46BE-A963-0BA3FC01DC78@saxonica.com> If the input and output are both in a namespace, and you want the output to be in a namespace but with no namespace prefix, then I think your options are: (a) Use *:name in path expressions (which may over-select) (b) Bind a prefix p to the input namespace and use p:name in path expressions (which is tedious) (c) Use Q{}name in path expressions (which is 3.0 only, and tedious) (d) Use computed element constructors, and binding the default namespace to the input namespace (e) Use XSLT 2.0 with the default-xpath-namespace attribute. Sadly, I remember trying to persuade the XQuery WG to allow different default namespaces for input and output element names, and the general reaction was "Mike, why do you keep trying to make namespaces even more complicated than they are already?". So XQuery repeated the mistake of XSLT 1.0, only in a slightly different form. Handling input documents with a default namespace remains by a good measure the #1 xpath usability problem, a new StackOverflow user falls into the trap nearly every day. Michael Kay Saxonica > On 1 Jun 2016, at 10:44, Ghislain Fourny wrote: > > Hi Leo, > > I'm glad! > > Should this happen, I guess you could add a filter using an XPath function to test for the namespace of the name of the selected element. > > https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name > and > https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName > > You can test for the absence of namespace easily. > > There may be even shorter tricks, I wouldn't be surprised if Mike got something out of his magic hat :-) > > Kind regards, > Ghislain > > > On Wed, Jun 1, 2016 at 11:38 AM, Leo Studer > wrote: > Hi Ghislain > > thank you for your input, which solves my problem. > > However, if I have the same element name in two different namespaces, then the use of a wildcard namespace makes problems ;-). > > Always > Leo > >> On 01 Jun 2016, at 11:06, Ghislain Fourny > wrote: >> >> Hi Leo, >> >> If the input has no namespace, then I think you can declare the default namespace according to your output (if it is important to you that your output uses it as a default namespace). >> >> Then there is a workaround to navigate the input with /*:foo/*:bar expressions, where the joker prefix should catch the absence of namespace. >> >> I hope it helps? >> >> Kind regards, >> Ghislain >> >> >> On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer > wrote: >> Hi Michael >> >> > >> > >> > The main difference from the XSLT xpath-default-namespace is that this default applies both to names in path expressions and to names in element constructors, which is inconvenient when the input and output documents are in different namespaces. >> > >> > Michael Kay >> > Saxonica >> >> this is exactly my problem. The XML file has no namespace and the output has a namespace. >> >> Fist I tried >> >> declare namespace null=??; >> >> and in the query I wrote something like >> >> null:elementName >> >> Then I get the error that namespace null is not declared?. >> >> The only solution I found is to put a namespace in the XML file (which is not really what I want). >> >> Is there another way? >> >> Cheers >> Leo >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > 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: From leo.studer at varioweb.ch Sun Jun 5 14:15:06 2016 From: leo.studer at varioweb.ch (Leo Studer) Date: Sun, 5 Jun 2016 23:15:06 +0200 Subject: [xquery-talk] xpath default namespace In-Reply-To: <5EDC98E6-36E5-46BE-A963-0BA3FC01DC78@saxonica.com> References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> <5EDC98E6-36E5-46BE-A963-0BA3FC01DC78@saxonica.com> Message-ID: <63BE1317-ABF7-4F5C-8F61-3E2092DBF28C@varioweb.ch> Thank you Mike And Ghislain may be xPath/xQuery 3.2 will have the possibility of different default namespaces for input and output elements ;-) and also the possibility to bind a prefix to the null namespace (??) ... Always Leo > On 01 Jun 2016, at 13:15, Michael Kay wrote: > > If the input and output are both in a namespace, and you want the output to be in a namespace but with no namespace prefix, then I think your options are: > > (a) Use *:name in path expressions (which may over-select) > > (b) Bind a prefix p to the input namespace and use p:name in path expressions (which is tedious) > > (c) Use Q{}name in path expressions (which is 3.0 only, and tedious) > > (d) Use computed element constructors, and binding the default namespace to the input namespace > > (e) Use XSLT 2.0 with the default-xpath-namespace attribute. > > Sadly, I remember trying to persuade the XQuery WG to allow different default namespaces for input and output element names, and the general reaction was "Mike, why do you keep trying to make namespaces even more complicated than they are already?". So XQuery repeated the mistake of XSLT 1.0, only in a slightly different form. > > Handling input documents with a default namespace remains by a good measure the #1 xpath usability problem, a new StackOverflow user falls into the trap nearly every day. > > Michael Kay > Saxonica > > > > >> On 1 Jun 2016, at 10:44, Ghislain Fourny > wrote: >> >> Hi Leo, >> >> I'm glad! >> >> Should this happen, I guess you could add a filter using an XPath function to test for the namespace of the name of the selected element. >> >> https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name >> and >> https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName >> >> You can test for the absence of namespace easily. >> >> There may be even shorter tricks, I wouldn't be surprised if Mike got something out of his magic hat :-) >> >> Kind regards, >> Ghislain >> >> >> On Wed, Jun 1, 2016 at 11:38 AM, Leo Studer > wrote: >> Hi Ghislain >> >> thank you for your input, which solves my problem. >> >> However, if I have the same element name in two different namespaces, then the use of a wildcard namespace makes problems ;-). >> >> Always >> Leo >> >>> On 01 Jun 2016, at 11:06, Ghislain Fourny > wrote: >>> >>> Hi Leo, >>> >>> If the input has no namespace, then I think you can declare the default namespace according to your output (if it is important to you that your output uses it as a default namespace). >>> >>> Then there is a workaround to navigate the input with /*:foo/*:bar expressions, where the joker prefix should catch the absence of namespace. >>> >>> I hope it helps? >>> >>> Kind regards, >>> Ghislain >>> >>> >>> On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer > wrote: >>> Hi Michael >>> >>> > >>> > >>> > The main difference from the XSLT xpath-default-namespace is that this default applies both to names in path expressions and to names in element constructors, which is inconvenient when the input and output documents are in different namespaces. >>> > >>> > Michael Kay >>> > Saxonica >>> >>> this is exactly my problem. The XML file has no namespace and the output has a namespace. >>> >>> Fist I tried >>> >>> declare namespace null=??; >>> >>> and in the query I wrote something like >>> >>> null:elementName >>> >>> Then I get the error that namespace null is not declared?. >>> >>> The only solution I found is to put a namespace in the XML file (which is not really what I want). >>> >>> Is there another way? >>> >>> Cheers >>> Leo >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> >> _______________________________________________ >> 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: From graydonish at gmail.com Sun Jun 5 14:20:13 2016 From: graydonish at gmail.com (Graydon Saunders) Date: Sun, 05 Jun 2016 21:20:13 +0000 Subject: [xquery-talk] xpath default namespace In-Reply-To: <63BE1317-ABF7-4F5C-8F61-3E2092DBF28C@varioweb.ch> References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> <5EDC98E6-36E5-46BE-A963-0BA3FC01DC78@saxonica.com> <63BE1317-ABF7-4F5C-8F61-3E2092DBF28C@varioweb.ch> Message-ID: And just possibly some way to flush the haze of unwanted namespaces clinging to the query result, too. -- Graydon On Sun, Jun 5, 2016, 17:17 Leo Studer wrote: > Thank you Mike And Ghislain > > may be xPath/xQuery 3.2 will have the possibility of different default > namespaces for input and output elements ;-) > and also the possibility to bind a prefix to the null namespace (??) ... > > Always > Leo > > > > On 01 Jun 2016, at 13:15, Michael Kay wrote: > > If the input and output are both in a namespace, and you want the output > to be in a namespace but with no namespace prefix, then I think your > options are: > > (a) Use *:name in path expressions (which may over-select) > > (b) Bind a prefix p to the input namespace and use p:name in path > expressions (which is tedious) > > (c) Use Q{}name in path expressions (which is 3.0 only, and tedious) > > (d) Use computed element constructors, and binding the default namespace > to the input namespace > > (e) Use XSLT 2.0 with the default-xpath-namespace attribute. > > Sadly, I remember trying to persuade the XQuery WG to allow different > default namespaces for input and output element names, and the general > reaction was "Mike, why do you keep trying to make namespaces even more > complicated than they are already?". So XQuery repeated the mistake of XSLT > 1.0, only in a slightly different form. > > Handling input documents with a default namespace remains by a good > measure the #1 xpath usability problem, a new StackOverflow user falls into > the trap nearly every day. > > Michael Kay > Saxonica > > > > > On 1 Jun 2016, at 10:44, Ghislain Fourny wrote: > > Hi Leo, > > I'm glad! > > Should this happen, I guess you could add a filter using an XPath function > to test for the namespace of the name of the selected element. > > > https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-node-name > and > > https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-30/html/Overview.html#func-namespace-uri-from-QName > > You can test for the absence of namespace easily. > > There may be even shorter tricks, I wouldn't be surprised if Mike got > something out of his magic hat :-) > > Kind regards, > Ghislain > > > On Wed, Jun 1, 2016 at 11:38 AM, Leo Studer > wrote: > >> Hi Ghislain >> >> thank you for your input, which solves my problem. >> >> However, if I have the same element name in two different namespaces, >> then the use of a wildcard namespace makes problems ;-). >> >> Always >> Leo >> >> On 01 Jun 2016, at 11:06, Ghislain Fourny wrote: >> >> Hi Leo, >> >> If the input has no namespace, then I think you can declare the default >> namespace according to your output (if it is important to you that your >> output uses it as a default namespace). >> >> Then there is a workaround to navigate the input with /*:foo/*:bar >> expressions, where the joker prefix should catch the absence of namespace. >> >> I hope it helps? >> >> Kind regards, >> Ghislain >> >> >> On Wed, Jun 1, 2016 at 10:20 AM, Leo Studer >> wrote: >> >>> Hi Michael >>> >>> > >>> > >>> > The main difference from the XSLT xpath-default-namespace is that this >>> default applies both to names in path expressions and to names in element >>> constructors, which is inconvenient when the input and output documents are >>> in different namespaces. >>> > >>> > Michael Kay >>> > Saxonica >>> >>> this is exactly my problem. The XML file has no namespace and the output >>> has a namespace. >>> >>> Fist I tried >>> >>> declare namespace null=??; >>> >>> and in the query I wrote something like >>> >>> null:elementName >>> >>> Then I get the error that namespace null is not declared?. >>> >>> The only solution I found is to put a namespace in the XML file (which >>> is not really what I want). >>> >>> Is there another way? >>> >>> Cheers >>> Leo >>> _______________________________________________ >>> talk at x-query.com >>> http://x-query.com/mailman/listinfo/talk >>> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > > > _______________________________________________ > 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: From liam at w3.org Sun Jun 5 23:30:33 2016 From: liam at w3.org (Liam R. E. Quin) Date: Mon, 06 Jun 2016 02:30:33 -0400 Subject: [xquery-talk] xpath default namespace In-Reply-To: <63BE1317-ABF7-4F5C-8F61-3E2092DBF28C@varioweb.ch> References: <264000A6-1899-425B-9366-039592CE7295@varioweb.ch> <730716A3-6A0C-4428-B0BC-80A31BE85607@saxonica.com> <33FA7AEA-AB7B-4C42-A83A-F24740F212DD@varioweb.ch> <472760DB-039D-4065-9EFC-3A33AAD42340@varioweb.ch> <5EDC98E6-36E5-46BE-A963-0BA3FC01DC78@saxonica.com> <63BE1317-ABF7-4F5C-8F61-3E2092DBF28C@varioweb.ch> Message-ID: <1465194633.330.117.camel@w3.org> On Sun, 2016-06-05 at 23:15 +0200, Leo Studer wrote: > Thank you Mike And Ghislain > > may be??xPath/xQuery 3.2 will have? I'm not expecting to see an XQuery 3.2 or XPath 3.2. I could always be surprised, there could be a sudden surge of interest and resources, but rightnow it's not looking likely. Liam -- Liam R. E. Quin The World Wide Web Consortium (W3C) From joewiz at gmail.com Thu Jun 9 15:53:08 2016 From: joewiz at gmail.com (Joe Wicentowski) Date: Thu, 9 Jun 2016 18:53:08 -0400 Subject: [xquery-talk] Can XQuery Update corrupt documents? Message-ID: 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 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 element, and I want to move the page number inside the 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From g at 28.io Fri Jun 10 01:01:43 2016 From: g at 28.io (Ghislain Fourny) Date: Fri, 10 Jun 2016 10:01:43 +0200 Subject: [xquery-talk] Can XQuery Update corrupt documents? In-Reply-To: References: Message-ID: Hi Joe, I'm not sure what's happening with the write-back, but looking at your code, it seems that the reconstruct function is not needed. Indeed, when you write, say: replace node $ref with $new-ref A copy of $new-ref is always made (this the semantics of XQuery Update), which is what is inserted. So even if $new-ref points to a node in the original document, this alone can't lead to an error. The same goes line 43: a copy is made, that's two in total. >From what I see, an insert-as-last into the ref element would be sufficient. I hope it helps! Kind regards, Ghislain On Fri, Jun 10, 2016 at 12:53 AM, Joe Wicentowski 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 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 element, and I want to move the page number inside the 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From g at 28.io Fri Jun 10 01:49:14 2016 From: g at 28.io (Ghislain Fourny) Date: Fri, 10 Jun 2016 10:49:14 +0200 Subject: [xquery-talk] Can XQuery Update corrupt documents? In-Reply-To: <9A04A223-E45C-46DC-A11E-333CF60EBB5A@saxonica.com> References: <9A04A223-E45C-46DC-A11E-333CF60EBB5A@saxonica.com> Message-ID: 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 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 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 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 element, and I > want to move the page number inside the 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: From joewiz at gmail.com Fri Jun 10 12:54:18 2016 From: joewiz at gmail.com (Joe Wicentowski) Date: Fri, 10 Jun 2016 15:54:18 -0400 Subject: [xquery-talk] Can XQuery Update corrupt documents? In-Reply-To: References: <9A04A223-E45C-46DC-A11E-333CF60EBB5A@saxonica.com> Message-ID: 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: For text of NSC 164/1, see Foreign Relations, 1952?1954, vol. VII, Part 2 , p. 1914. After transformation: For text of NSC 164/1, see Foreign Relations, 1952?1954, vol. VII, Part 2, p. 1914 . 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 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 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 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 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 element, and I >> want to move the page number inside the 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: