Xquery with basex Cdata
Hi,
I try to extract the Cdata by the follow query:
for $x in doc('input.xml')//App//package//text() return $xOn the follow xml
<?xml version="1.0" encoding="UTF-8"?>
<App name="BasexTest_1">
<package name="main/resources/xml">
<![CDATA[ -- dd --]]>
<!-- ff -->
<file name="input.xml"></file>
</package>
<!-- ff -->
<package name="org/basex/examples/local">
<file name="RunCommands.java"></file>
<!-- dd -->
<!-- ff -->
<folder>lib</folder></package>
</App>and it is not return the cdata ,why ?
Thanks Eitan
Hi Eitan,
works for me. What is your expected output and what do you get instead?
General advise for your query: Using / instead of // would be sufficient in this case and is in general is much more performant.
Cheers, Dirk
Quoted text · eitan elmalam · 36 lines
On 24/02/14 08:23, eitan elmalam wrote: > Hi, > > I try to extract the Cdata by the follow query: > > for $x in doc('input.xml')//App//package//text() return $x > > On the follow xml > > <?xml version="1.0" encoding="UTF-8"?> > <App name="BasexTest_1"> > <package name="main/resources/xml"> > <![CDATA[ -- dd --]]> > <!-- ff --> > <file name="input.xml"></file> > </package> > <!-- ff --> > <package name="org/basex/examples/local"> > <file name="RunCommands.java"></file> > <!-- dd --> > <!-- ff --> > <folder>lib</folder></package> > </App> > > and it is not return the cdata ,why ? > > Thanks > Eitan > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Hi Eitan, perhaps there is a misunderstanding concerning CDATA sections?
In case you are not aware of it: 1) XQuery cannot see CDATA sections - their content is just part of the text content. Regard it as an evelope which does not influence the letter contained. As a consequence, it is principally not possible to *select* any text based on whether or not they are in CDATA sections. 2) XQuery output does not use CDATA sections, unless you supply the serialization parameter "cdata-section-elements", which contains a whitespace-separated list of element names. The contents of these elements will then by serialized as CDATA sections.
Example: basex -i input.xml -s "cdata-section-elements=package folder" myquery.xq
Kind regards, Hans-Juergen
Quoted text · Dirk Kirsten · 1 line
Dirk Kirsten <dk at basex.org> schrieb am 9:43 Montag, 24.Februar 2014:
Hi Eitan,
works for me. What is your expected output and what do you get instead?
General advise for your query: Using / instead of // would be sufficient in this case and is in general is much more performant.
Cheers, Dirk
Quoted text · eitan elmalam · 37 lines
On 24/02/14 08:23, eitan elmalam wrote: > Hi, > > I try to extract the Cdata by the follow query: > > for $x in doc('input.xml')//App//package//text() return $x > > On the follow xml > > <?xml version="1.0" encoding="UTF-8"?> > <App name="BasexTest_1"> > <package name="main/resources/xml"> > <![CDATA[ -- dd --]]> > <!-- ff --> > <file name="input.xml"></file> > </package> > <!-- ff --> > <package name="org/basex/examples/local"> > <file name="RunCommands.java"></file> > <!-- dd --> > <!-- ff --> > <folder>lib</folder></package> > </App> > > and it is not return the cdata ,why ? > > Thanks > Eitan > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 7.8. BaseX may have changed since: please check the current documentation.