Marklogic How to exclude multiple nodes in xml
up vote
2
down vote
favorite
I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.
[(fn:local-name() != ("Sources","Navigators")]
In Marklogic Qconsole:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
marklogic
add a comment |
up vote
2
down vote
favorite
I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.
[(fn:local-name() != ("Sources","Navigators")]
In Marklogic Qconsole:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
marklogic
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.
[(fn:local-name() != ("Sources","Navigators")]
In Marklogic Qconsole:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
marklogic
I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.
[(fn:local-name() != ("Sources","Navigators")]
In Marklogic Qconsole:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
marklogic
marklogic
edited Nov 9 at 20:34
grtjn
14.7k11730
14.7k11730
asked Nov 9 at 19:43
thichxai
31926
31926
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You have a open parenthesis too many in front of fn:local-name()
.
However, you could also make use of the except
keyword, and a prefix wildcard. You would use it like this:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/(* except (*:Sources, *:Navigators))
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
HTH!
add a comment |
up vote
2
down vote
The !=
operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as !=
to "Navigators", and when it finds a *:Navigators node, it evaluates as !=
to "Sources". And then you get all the nodes.
If you aren't comparing node sequences (so except
is not an option), then instead of !=
, you can use fn:not(A = B)
to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators"))
should work as you expect.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You have a open parenthesis too many in front of fn:local-name()
.
However, you could also make use of the except
keyword, and a prefix wildcard. You would use it like this:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/(* except (*:Sources, *:Navigators))
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
HTH!
add a comment |
up vote
1
down vote
accepted
You have a open parenthesis too many in front of fn:local-name()
.
However, you could also make use of the except
keyword, and a prefix wildcard. You would use it like this:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/(* except (*:Sources, *:Navigators))
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
HTH!
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You have a open parenthesis too many in front of fn:local-name()
.
However, you could also make use of the except
keyword, and a prefix wildcard. You would use it like this:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/(* except (*:Sources, *:Navigators))
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
HTH!
You have a open parenthesis too many in front of fn:local-name()
.
However, you could also make use of the except
keyword, and a prefix wildcard. You would use it like this:
for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/(* except (*:Sources, *:Navigators))
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml
HTH!
answered Nov 9 at 20:34
grtjn
14.7k11730
14.7k11730
add a comment |
add a comment |
up vote
2
down vote
The !=
operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as !=
to "Navigators", and when it finds a *:Navigators node, it evaluates as !=
to "Sources". And then you get all the nodes.
If you aren't comparing node sequences (so except
is not an option), then instead of !=
, you can use fn:not(A = B)
to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators"))
should work as you expect.
add a comment |
up vote
2
down vote
The !=
operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as !=
to "Navigators", and when it finds a *:Navigators node, it evaluates as !=
to "Sources". And then you get all the nodes.
If you aren't comparing node sequences (so except
is not an option), then instead of !=
, you can use fn:not(A = B)
to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators"))
should work as you expect.
add a comment |
up vote
2
down vote
up vote
2
down vote
The !=
operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as !=
to "Navigators", and when it finds a *:Navigators node, it evaluates as !=
to "Sources". And then you get all the nodes.
If you aren't comparing node sequences (so except
is not an option), then instead of !=
, you can use fn:not(A = B)
to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators"))
should work as you expect.
The !=
operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as !=
to "Navigators", and when it finds a *:Navigators node, it evaluates as !=
to "Sources". And then you get all the nodes.
If you aren't comparing node sequences (so except
is not an option), then instead of !=
, you can use fn:not(A = B)
to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators"))
should work as you expect.
answered Nov 10 at 4:49
BenW
31817
31817
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232329%2fmarklogic-how-to-exclude-multiple-nodes-in-xml%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown