Strange behaviour when applying fn:data to info-node
When I run the following xquery in MarkLogic":
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>hello</info>
</envelope>
return fn:data($envelope/es:info)
I receive this error:
[1.0-ml] XDMP-NONMIXEDCOMPLEXCONT: fn:data(hello) -- Node has complex type with non-mixed complex content
Strangely, when I rename the info-node to info1 for instance the code works as expected:
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info1>hello</info1>
</envelope>
return fn:data($envelope/es:info1)
result is: hello (as expected)
Can someone explain this black magic to me?
marklogic marklogic-9
add a comment |
When I run the following xquery in MarkLogic":
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>hello</info>
</envelope>
return fn:data($envelope/es:info)
I receive this error:
[1.0-ml] XDMP-NONMIXEDCOMPLEXCONT: fn:data(hello) -- Node has complex type with non-mixed complex content
Strangely, when I rename the info-node to info1 for instance the code works as expected:
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info1>hello</info1>
</envelope>
return fn:data($envelope/es:info1)
result is: hello (as expected)
Can someone explain this black magic to me?
marklogic marklogic-9
add a comment |
When I run the following xquery in MarkLogic":
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>hello</info>
</envelope>
return fn:data($envelope/es:info)
I receive this error:
[1.0-ml] XDMP-NONMIXEDCOMPLEXCONT: fn:data(hello) -- Node has complex type with non-mixed complex content
Strangely, when I rename the info-node to info1 for instance the code works as expected:
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info1>hello</info1>
</envelope>
return fn:data($envelope/es:info1)
result is: hello (as expected)
Can someone explain this black magic to me?
marklogic marklogic-9
When I run the following xquery in MarkLogic":
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>hello</info>
</envelope>
return fn:data($envelope/es:info)
I receive this error:
[1.0-ml] XDMP-NONMIXEDCOMPLEXCONT: fn:data(hello) -- Node has complex type with non-mixed complex content
Strangely, when I rename the info-node to info1 for instance the code works as expected:
xquery version "1.0-ml";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info1>hello</info1>
</envelope>
return fn:data($envelope/es:info1)
result is: hello (as expected)
Can someone explain this black magic to me?
marklogic marklogic-9
marklogic marklogic-9
asked Jan 2 at 13:34
T. PhilippiT. Philippi
323
323
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
MarkLogic tries to retrieve a typed value from your data when using fn:data()
. MarkLogic will look for an appropriate schema for that purpose. Since you are using the entity-services namespace, it will look for the entity-services schema. This schema has a particular definition of the info
element (as correctly mentioned by Michael), which doesn't match the way you use it.
Using fn:string()
instead of fn:data()
is usually more robust, since it will by-pass data type checking. Using an element name which is not defined in the entity-services schema is gives you a quick fix that will work now, but it might be tricky to guarantee it will work in future as well.
Personally, I'd advice to use the entity-services namespace as intended. If you need to put in additional elements, put them in a different namespace, with or without an accompanying schema. Or, simply drop the namespace entirely.
HTH!
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
add a comment |
I guess this is because the schema entity-type.xsd
defines the elements as non-mixed:
<xs:complexType name="InfoType">
<xs:sequence>
<xs:element ref="es:title"/>
<xs:element ref="es:version"/>
<xs:element ref="es:base-uri" minOccurs="0"/>
<xs:element ref="es:description" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="info" type="es:InfoType"/>
A element can be of mixed content if it has a mixed="true"
attribute. Because you cannot change the schema in this case, i'd try using string()
.
declare namespace es = "http://marklogic.com/entity-services";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>
<title>hello</title>
<version>1.0</version>
</info>
</envelope>
return $envelope/es:info/string()
This gives you hello1.0
as a result if this is what you wanted.
Your example with info1
works, because this element is not defined in the schema (and thus wouldn't be a valid xml).
add a comment |
Because fn:data() has potential interactions with schemas, consider using fn:string() to get the text of an element as a string.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f54007339%2fstrange-behaviour-when-applying-fndata-to-info-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
MarkLogic tries to retrieve a typed value from your data when using fn:data()
. MarkLogic will look for an appropriate schema for that purpose. Since you are using the entity-services namespace, it will look for the entity-services schema. This schema has a particular definition of the info
element (as correctly mentioned by Michael), which doesn't match the way you use it.
Using fn:string()
instead of fn:data()
is usually more robust, since it will by-pass data type checking. Using an element name which is not defined in the entity-services schema is gives you a quick fix that will work now, but it might be tricky to guarantee it will work in future as well.
Personally, I'd advice to use the entity-services namespace as intended. If you need to put in additional elements, put them in a different namespace, with or without an accompanying schema. Or, simply drop the namespace entirely.
HTH!
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
add a comment |
MarkLogic tries to retrieve a typed value from your data when using fn:data()
. MarkLogic will look for an appropriate schema for that purpose. Since you are using the entity-services namespace, it will look for the entity-services schema. This schema has a particular definition of the info
element (as correctly mentioned by Michael), which doesn't match the way you use it.
Using fn:string()
instead of fn:data()
is usually more robust, since it will by-pass data type checking. Using an element name which is not defined in the entity-services schema is gives you a quick fix that will work now, but it might be tricky to guarantee it will work in future as well.
Personally, I'd advice to use the entity-services namespace as intended. If you need to put in additional elements, put them in a different namespace, with or without an accompanying schema. Or, simply drop the namespace entirely.
HTH!
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
add a comment |
MarkLogic tries to retrieve a typed value from your data when using fn:data()
. MarkLogic will look for an appropriate schema for that purpose. Since you are using the entity-services namespace, it will look for the entity-services schema. This schema has a particular definition of the info
element (as correctly mentioned by Michael), which doesn't match the way you use it.
Using fn:string()
instead of fn:data()
is usually more robust, since it will by-pass data type checking. Using an element name which is not defined in the entity-services schema is gives you a quick fix that will work now, but it might be tricky to guarantee it will work in future as well.
Personally, I'd advice to use the entity-services namespace as intended. If you need to put in additional elements, put them in a different namespace, with or without an accompanying schema. Or, simply drop the namespace entirely.
HTH!
MarkLogic tries to retrieve a typed value from your data when using fn:data()
. MarkLogic will look for an appropriate schema for that purpose. Since you are using the entity-services namespace, it will look for the entity-services schema. This schema has a particular definition of the info
element (as correctly mentioned by Michael), which doesn't match the way you use it.
Using fn:string()
instead of fn:data()
is usually more robust, since it will by-pass data type checking. Using an element name which is not defined in the entity-services schema is gives you a quick fix that will work now, but it might be tricky to guarantee it will work in future as well.
Personally, I'd advice to use the entity-services namespace as intended. If you need to put in additional elements, put them in a different namespace, with or without an accompanying schema. Or, simply drop the namespace entirely.
HTH!
answered Jan 7 at 10:06
grtjngrtjn
16k11931
16k11931
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
add a comment |
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
Thanks for this explanation! It wasn't clear from the marklogic documentation, that fn:data() actually searched for schema's. And actually we were using xdmp:hash64() which uses fn:data underwater, so in our case the solution was to use fn:string(xdmp:hash64($variable))
– T. Philippi
Jan 8 at 16:17
add a comment |
I guess this is because the schema entity-type.xsd
defines the elements as non-mixed:
<xs:complexType name="InfoType">
<xs:sequence>
<xs:element ref="es:title"/>
<xs:element ref="es:version"/>
<xs:element ref="es:base-uri" minOccurs="0"/>
<xs:element ref="es:description" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="info" type="es:InfoType"/>
A element can be of mixed content if it has a mixed="true"
attribute. Because you cannot change the schema in this case, i'd try using string()
.
declare namespace es = "http://marklogic.com/entity-services";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>
<title>hello</title>
<version>1.0</version>
</info>
</envelope>
return $envelope/es:info/string()
This gives you hello1.0
as a result if this is what you wanted.
Your example with info1
works, because this element is not defined in the schema (and thus wouldn't be a valid xml).
add a comment |
I guess this is because the schema entity-type.xsd
defines the elements as non-mixed:
<xs:complexType name="InfoType">
<xs:sequence>
<xs:element ref="es:title"/>
<xs:element ref="es:version"/>
<xs:element ref="es:base-uri" minOccurs="0"/>
<xs:element ref="es:description" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="info" type="es:InfoType"/>
A element can be of mixed content if it has a mixed="true"
attribute. Because you cannot change the schema in this case, i'd try using string()
.
declare namespace es = "http://marklogic.com/entity-services";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>
<title>hello</title>
<version>1.0</version>
</info>
</envelope>
return $envelope/es:info/string()
This gives you hello1.0
as a result if this is what you wanted.
Your example with info1
works, because this element is not defined in the schema (and thus wouldn't be a valid xml).
add a comment |
I guess this is because the schema entity-type.xsd
defines the elements as non-mixed:
<xs:complexType name="InfoType">
<xs:sequence>
<xs:element ref="es:title"/>
<xs:element ref="es:version"/>
<xs:element ref="es:base-uri" minOccurs="0"/>
<xs:element ref="es:description" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="info" type="es:InfoType"/>
A element can be of mixed content if it has a mixed="true"
attribute. Because you cannot change the schema in this case, i'd try using string()
.
declare namespace es = "http://marklogic.com/entity-services";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>
<title>hello</title>
<version>1.0</version>
</info>
</envelope>
return $envelope/es:info/string()
This gives you hello1.0
as a result if this is what you wanted.
Your example with info1
works, because this element is not defined in the schema (and thus wouldn't be a valid xml).
I guess this is because the schema entity-type.xsd
defines the elements as non-mixed:
<xs:complexType name="InfoType">
<xs:sequence>
<xs:element ref="es:title"/>
<xs:element ref="es:version"/>
<xs:element ref="es:base-uri" minOccurs="0"/>
<xs:element ref="es:description" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="info" type="es:InfoType"/>
A element can be of mixed content if it has a mixed="true"
attribute. Because you cannot change the schema in this case, i'd try using string()
.
declare namespace es = "http://marklogic.com/entity-services";
let $envelope := <envelope xmlns="http://marklogic.com/entity-services">
<info>
<title>hello</title>
<version>1.0</version>
</info>
</envelope>
return $envelope/es:info/string()
This gives you hello1.0
as a result if this is what you wanted.
Your example with info1
works, because this element is not defined in the schema (and thus wouldn't be a valid xml).
answered Jan 2 at 13:56
Wagner MichaelWagner Michael
1,361822
1,361822
add a comment |
add a comment |
Because fn:data() has potential interactions with schemas, consider using fn:string() to get the text of an element as a string.
add a comment |
Because fn:data() has potential interactions with schemas, consider using fn:string() to get the text of an element as a string.
add a comment |
Because fn:data() has potential interactions with schemas, consider using fn:string() to get the text of an element as a string.
Because fn:data() has potential interactions with schemas, consider using fn:string() to get the text of an element as a string.
answered Jan 2 at 19:50
ehennumehennum
5,49197
5,49197
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f54007339%2fstrange-behaviour-when-applying-fndata-to-info-node%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