Dirk,
Thanks for your reply. Here's a simple example. When I run this query with Saxon HE 9.6, the output contains a CDATA section, but when I run it in the BaseX GUI, there is no CDATA and the angle brackets are escaped. Has this serialization parameter been implemented in BaseX?
xquery version "3.0";
declare copy-namespaces no-preserve, no-inherit; declare default element namespace "http://www.w3.org/1999/xhtml"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization "; declare option output:method "xhtml"; declare option output:indent "yes"; declare option output:encoding "utf-8"; declare option output:cdata-section-elements "script";
let $turtle := <turtle> <![CDATA[ @prefix ex: http://example.org/ . @prefix test: http://test.org/ .
ex:test1 a test:Test . ]]> </turtle>
let $html := <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> <title>Turtle Test</title> </head> <body> <h1>Turtle Test</h1> <script type="text/turtle">{ $turtle/text() }</script> </body> </html>
return $html
Saxon output:
<?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Turtle Test</title> </head> <body> <h1>Turtle Test</h1> <script type="text/turtle"><![CDATA[
@prefix ex: http://example.org/ . @prefix test: http://test.org/ .
ex:test1 a test:Test .
]]></script> </body> </html>
BaseX output:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <title>Turtle Test</title> </head> <body> <h1>Turtle Test</h1> <script type="text/turtle">
@prefix ex: <http://example.org/%3E; . @prefix test: <http://test.org/%3E; .
ex:test1 a test:Test .
</script> </body> </html>
-- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library
On Fri, Jul 10, 2015 at 4:39 AM, Dirk Kirsten dk@basex.org wrote:
Hello Tim,
CDATA is just ordinary (encoded) text to XQuery, i.e. there is no special CDATA data type. Therefore, instead of saving the document in this way you should adapt the output accordingly. So when you serialize your output you can use the map {"cdata-section-elements": "script"} to output the result as CDATA section. You can read a bit more about this in our documentation at http://docs.basex.org/wiki/Serialization
Cheers Dirk
On 07/09/2015 08:31 PM, Tim Thompson wrote:
Hello,
I am trying to retrieve some non-XML RDF data (as "text/turtle") from a SPARQL endpoint. I need to output the Turtle as a CDATA section inside a <script> tag in an XForms (X)HTML file, then add that file to a database.
The file gets added correctly, but I'm not able to generate the CDATA section. Here is the function:
db:add("xforms", document { $xslt-pi, $css, $form }, "turtle-test.xml", map {"cdata-section-elements": "script"})
When I run this, I get an error: [bxerr:BASX0002] Unknown database option 'cdata-section-elements'.
I get the same error no matter which option I use (not just "cdata-section-elements"), so I guess I may be using the wrong syntax.
Hope someone can point me in the right direction!
Thanks in advance, Tim
-- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22