[MarkLogic Dev General] Treating elements as byte strings
Karl Erisman
karl.erisman at gmail.com
Thu Oct 7 11:26:39 PDT 2010
I would like to take an element node and treat part of it as a string
in the same way it was originally declared (lexical equivalence, not
just semantic equivalence). Here is an example that does NOT do what
I want:
declare namespace ns="namespace";
let $elem := <xml><ns:xml>hi</ns:xml></xml>
return xdmp:quote($elem/*)
=> <ns:xml xmlns:ns="namespace">hi</ns:xml>
This returns a string representing semantically equivalent XML, but it
differs lexically from the original.
After $elem is stored as an element node, only its tree structure is
stored, correct? So the only way for me to do what I'm describing
would be for *me* to save the string form of the element at the time
it is declared. Is this correct?
BTW: As background, the reason I need to do this is to comply with a
spec that requires computing the "size" of incoming data, which may or
may not be XML (and the "size" is specific to the way the XML is
declared -- it is lexically significant). The data is sent as part of
a larger XML element, and by the time it arrives at the module
responsible for checking the size, it is already in XML. This is fine
for text nodes (fn:string-length gives the "size"), but not for
element nodes. If my understanding is correct, I'll need to make
modifications to lower-level modules so the original XML is available.
Thanks,
Karl
More information about the General
mailing list