Re: [MarkLogic Dev General] xsl:output, character maps and document-insert
Yeah, the xdmp:save gives you a serialized version to look at directly and check. There's a little more on this here: https://help.marklogic.com/knowledgebase/article/View/328/0/xml-serialization-and-output-options /ch On Wed, Nov 8, 2017 at 11:31 AM, Mark Donoghuewrote: > Christopher, thank you for responding :-) I was experimenting with your > suggestion (it worked) when Mary's response arrived. > > Mary, thank you for the information and workaround! > > It was surprising to find out the difference between writing back to the > database and serializing. I assumed it would be serialized everywhere. > > Best, > Mark > > - -- --- - - > Mark Donoghue > IEEE > (732) 562-6045 > m.donog...@ieee.org > > IEEE - Advancing Technology for Humanity > > On Wed, Nov 8, 2017 at 10:19 AM, Mary Holstege > wrote: >> >> >> Character maps apply to serializations. What gets stored in the database >> isn't serialized: it is a data model instance, that isn't serialized >> unless it is (a) rendered as output from a query (b) saved to disk or (c) >> explicitly serialized as a string via xdmp:quote. >> >> There is a special pass-through that when a document is returned from XSLT >> and returned as a result of the query, the XSLT serialization options will >> be applied, but that only works within the context of a single query. >> >> Try this: force a serialization using xdmp:quote and saving the reparse of >> that, e.g. >> xdmp:document-insert("/my.xml", xdmp:unquote(xdmp:quote($doc)) ) >> >> I think that should work. Round-tripping a serialization/parse to/from >> disk should also work, e.g. >> xdmp:document-insert("/my.xml", xdmp:document-get("/tmp/my.xml", >> xdmp:save("/tmp/my.xml",$doc))) >> >> Failing that, you'll need to do a manual sweep-replace yourself so that >> the data model instance you save has the characters in it that you want. >> >> //Mary >> >> >> On Tue, 07 Nov 2017 15:22:41 -0800, Mark Donoghue >> wrote: >> >> > Hi, >> > >> > >> > I am running a query in the query console that retrieves a document from >> > the >> > database, invokes an XSLT and stores the result over the same document >> > URI. >> > >> > >> > The purpose of the XSLT is to unescape double-escaped character entities >> > (i.e.: >> > amp;). Following what I thought was standard practice, the XSLT >> > replaces &'s >> > with and uses a character map to swap the private character >> > with an >> > ampersand on output (using the use-character-maps on the xsl:output >> > element). >> > >> > >> > This works fine in oXygen and even in the query console tests where I >> > output the >> > result document to the output pane. >> > >> > >> > The problem occurs when I retrieve the document from the database. The >> > private >> > character is still in the result document I stored, and hasn't >> > been >> > replaced with an ampersand. >> > >> > >> > Does document-insert (or something) ignore the xsl:output directives in >> > the >> > stylesheet? >> > >> > >> > Am I running into some some query console behavior I'm not aware of (I'm >> > still >> > rather new at using MarkLogic). >> > >> > >> > Any pointers in the right direction will he much appreciated. >> > >> > >> > Best, >> > >> > Mark >> > >> > >> > - -- --- - - >> > Mark Donoghue >> > >> > IEEE >> > >> > (732) 562-6045 >> > >> > m.donog...@ieee.org >> > >> > >> > IEEE - Advancing Technology for Humanity >> >> >> -- >> Using Opera's revolutionary email client: http://www.opera.com/mail/ >> ___ >> General mailing list >> General@developer.marklogic.com >> Manage your subscription at: >> http://developer.marklogic.com/mailman/listinfo/general > > > > ___ > General mailing list > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
Re: [MarkLogic Dev General] xsl:output, character maps and document-insert
Christopher, thank you for responding :-) I was experimenting with your suggestion (it worked) when Mary's response arrived. Mary, thank you for the information and workaround! It was surprising to find out the difference between writing back to the database and serializing. I assumed it would be serialized everywhere. Best, Mark - -- --- - - Mark Donoghue IEEE (732) 562-6045 m.donog...@ieee.org IEEE - Advancing Technology for Humanity On Wed, Nov 8, 2017 at 10:19 AM, Mary Holstegewrote: > > Character maps apply to serializations. What gets stored in the database > isn't serialized: it is a data model instance, that isn't serialized > unless it is (a) rendered as output from a query (b) saved to disk or (c) > explicitly serialized as a string via xdmp:quote. > > There is a special pass-through that when a document is returned from XSLT > and returned as a result of the query, the XSLT serialization options will > be applied, but that only works within the context of a single query. > > Try this: force a serialization using xdmp:quote and saving the reparse of > that, e.g. > xdmp:document-insert("/my.xml", xdmp:unquote(xdmp:quote($doc)) ) > > I think that should work. Round-tripping a serialization/parse to/from > disk should also work, e.g. > xdmp:document-insert("/my.xml", xdmp:document-get("/tmp/my.xml", > xdmp:save("/tmp/my.xml",$doc))) > > Failing that, you'll need to do a manual sweep-replace yourself so that > the data model instance you save has the characters in it that you want. > > //Mary > > > On Tue, 07 Nov 2017 15:22:41 -0800, Mark Donoghue > wrote: > > > Hi, > > > > > > I am running a query in the query console that retrieves a document from > > the > > database, invokes an XSLT and stores the result over the same document > > URI. > > > > > > The purpose of the XSLT is to unescape double-escaped character entities > > (i.e.: > > amp;). Following what I thought was standard practice, the XSLT > > replaces &'s > > with and uses a character map to swap the private character > > with an > > ampersand on output (using the use-character-maps on the xsl:output > > element). > > > > > > This works fine in oXygen and even in the query console tests where I > > output the > > result document to the output pane. > > > > > > The problem occurs when I retrieve the document from the database. The > > private > > character is still in the result document I stored, and hasn't > > been > > replaced with an ampersand. > > > > > > Does document-insert (or something) ignore the xsl:output directives in > > the > > stylesheet? > > > > > > Am I running into some some query console behavior I'm not aware of (I'm > > still > > rather new at using MarkLogic). > > > > > > Any pointers in the right direction will he much appreciated. > > > > > > Best, > > > > Mark > > > > > > - -- --- - - > > Mark Donoghue > > > > IEEE > > > > (732) 562-6045 > > > > m.donog...@ieee.org > > > > > > IEEE - Advancing Technology for Humanity > > > -- > Using Opera's revolutionary email client: http://www.opera.com/mail/ > ___ > General mailing list > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
Re: [MarkLogic Dev General] xsl:output, character maps and document-insert
Character maps apply to serializations. What gets stored in the database isn't serialized: it is a data model instance, that isn't serialized unless it is (a) rendered as output from a query (b) saved to disk or (c) explicitly serialized as a string via xdmp:quote. There is a special pass-through that when a document is returned from XSLT and returned as a result of the query, the XSLT serialization options will be applied, but that only works within the context of a single query. Try this: force a serialization using xdmp:quote and saving the reparse of that, e.g. xdmp:document-insert("/my.xml", xdmp:unquote(xdmp:quote($doc)) ) I think that should work. Round-tripping a serialization/parse to/from disk should also work, e.g. xdmp:document-insert("/my.xml", xdmp:document-get("/tmp/my.xml", xdmp:save("/tmp/my.xml",$doc))) Failing that, you'll need to do a manual sweep-replace yourself so that the data model instance you save has the characters in it that you want. //Mary On Tue, 07 Nov 2017 15:22:41 -0800, Mark Donoghuewrote: > Hi, > > > I am running a query in the query console that retrieves a document from > the > database, invokes an XSLT and stores the result over the same document > URI. > > > The purpose of the XSLT is to unescape double-escaped character entities > (i.e.: > amp;). Following what I thought was standard practice, the XSLT > replaces &'s > with and uses a character map to swap the private character > with an > ampersand on output (using the use-character-maps on the xsl:output > element). > > > This works fine in oXygen and even in the query console tests where I > output the > result document to the output pane. > > > The problem occurs when I retrieve the document from the database. The > private > character is still in the result document I stored, and hasn't > been > replaced with an ampersand. > > > Does document-insert (or something) ignore the xsl:output directives in > the > stylesheet? > > > Am I running into some some query console behavior I'm not aware of (I'm > still > rather new at using MarkLogic). > > > Any pointers in the right direction will he much appreciated. > > > Best, > > Mark > > > - -- --- - - > Mark Donoghue > > IEEE > > (732) 562-6045 > > m.donog...@ieee.org > > > IEEE - Advancing Technology for Humanity -- Using Opera's revolutionary email client: http://www.opera.com/mail/ ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
Re: [MarkLogic Dev General] xsl:output, character maps and document-insert
Sometimes query console output can be misleading, since it's creating a display. Another way to test is xdmp:save to the disk and look there. Do you have a small example to try? /ch On Tue, Nov 7, 2017 at 6:22 PM, Mark Donoghuewrote: > Hi, > > I am running a query in the query console that retrieves a document from the > database, invokes an XSLT and stores the result over the same document URI. > > The purpose of the XSLT is to unescape double-escaped character entities > (i.e.: amp;). Following what I thought was standard practice, the XSLT > replaces &'s with and uses a character map to swap the private > character with an ampersand on output (using the use-character-maps on the > xsl:output element). > > This works fine in oXygen and even in the query console tests where I output > the result document to the output pane. > > The problem occurs when I retrieve the document from the database. The > private character is still in the result document I stored, and > hasn't been replaced with an ampersand. > > Does document-insert (or something) ignore the xsl:output directives in the > stylesheet? > > Am I running into some some query console behavior I'm not aware of (I'm > still rather new at using MarkLogic). > > Any pointers in the right direction will he much appreciated. > > Best, > Mark > > - -- --- - - > Mark Donoghue > IEEE > (732) 562-6045 > m.donog...@ieee.org > > IEEE - Advancing Technology for Humanity > > ___ > General mailing list > General@developer.marklogic.com > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
[MarkLogic Dev General] xsl:output, character maps and document-insert
Hi, I am running a query in the query console that retrieves a document from the database, invokes an XSLT and stores the result over the same document URI. The purpose of the XSLT is to unescape double-escaped character entities (i.e.: amp;). Following what I thought was standard practice, the XSLT replaces &'s with and uses a character map to swap the private character with an ampersand on output (using the use-character-maps on the xsl:output element). This works fine in oXygen and even in the query console tests where I output the result document to the output pane. The problem occurs when I retrieve the document from the database. The private character is still in the result document I stored, and hasn't been replaced with an ampersand. Does document-insert (or something) ignore the xsl:output directives in the stylesheet? Am I running into some some query console behavior I'm not aware of (I'm still rather new at using MarkLogic). Any pointers in the right direction will he much appreciated. Best, Mark - -- --- - - Mark Donoghue IEEE (732) 562-6045 m.donog...@ieee.org IEEE - Advancing Technology for Humanity ___ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general