I am pulling a document from the database, selecting a part of the document, and transforming that part to json using json:transform-to-json, using an empty json:config("custom")
for the configuration. The xml part that I am selecting does not have any attributes, only elements, yet in the transformation something is triggering the case where an element has both a value and an attribute, and is adding a _value
element to the json which contains newline characters.
Here is a test program I ran where I pulled the content from the database, and returned the content, the transform of the content, and then a transform of hardcoded content which I had just copied from the console for the first part. My expectation is that the transformations would be the same, but they are not.
import module namespace json="http://marklogic.com/xdmp/json"
at "/MarkLogic/json/json.xqy";
declare namespace pdbm = "http://schemas.abbvienet.com/people-db/model";
let $person := fn:collection()[1]//pdbm:person/pdbm:account
let $node :=
<account xmlns:pdbe="http://schemas.abbvienet.com/people-db/envelope" xmlns="http://schemas.abbvienet.com/people-db/model">
<domain>ABBVIENET</domain>
<username>KOPECOX</username>
<status>ENABLED</status>
</account>
return ($person, json:transform-to-json($person, json:config("custom")), json:transform-to-json($node, json:config("custom")))
The selected content from the db, $person in this case transforms to:
{
"account": {
"domain": "ABBVIENET",
"username": "KOPECOX",
"status": "ENABLED",
"_value": "\n "
}
}
Whereas the $node, which is exactly the same content transforms to:
{
"account": {
"domain": "ABBVIENET",
"username": "KOPECOX",
"status": "ENABLED"
}
}