[oXygen-user] Possible to use XQuery Update to Update attribute values and get literal newlines?

Eliot Kimber ekimber at contrext.com
Thu Mar 13 08:13:56 CDT 2014


I'm pretty sure the answer is "no", but I'm wondering if there's any way
to use XQuery update via Saxon to update an attribute value such that the
resulting value has literal newline characters in it.

In the context of the DITA 1.3 RNG stuff, I've written a little XQuery
transform that updates the default value of the @domains attribute as
declared in a document type shell's grammar doc.

The value of the a:defaultValue attribute as I've coded it is formatted
like so:

      <attribute name="domains"
        a:defaultValue="
(topic topic)
        (topic hazard-d)
        (topic hi-d)
        (topic indexing-d)
        (topic ut-d)
        (topic hazard-d)
        a(props deliveryTarget)
"/>

Which is consistent with the general DITA coding practice of putting
each thing on its own line for each of updating and so on.

However, the XQuery update will not emit literal newlines using any method
I've tried. This is consistent with the fact that newlines in XML
attributes are treated as space characters when the XML is parsed.

That is, if I do:

let $domains := string-join(local:getDomainsContributions($e),
                            '&#x0a;')

Then what I get in the updated document is:

a:defaultValue="(topic abbrev-d) &#xA;(topic equation-d) &#xA;(topic
hazard-d) &#xA;(topic hi-d) &#xA;(topic indexing-d) &#xA;(topic mathml-d)
&#xA;(topic pr-d) &#xA;(topic relmgmt-d)"

Which is technically correct per the XML spec but not what I wanted.

Is there any solution here other than simply doing a global search and
replace on &#xA; (which is OK but not as automatic as I had hoped I could
do).



Thanks,

Eliot
—————
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com





More information about the oXygen-user mailing list