How does one insert an arbitrary file. doc('q') parses it. How does one just, you know, #include q as in C?
On Wed, May 9, 2012 at 3:28 PM, jidanni@jidanni.org wrote:
How does one insert an arbitrary file. doc('q') parses it. How does one just, you know, #include q as in C?
Hm, where do you want to include your file? Do you have a small, concise example? C.
<body> {insert_file("blob_of_bytes")} <h1>
..try file:read-text() or file:read-binary():
"CG" == Christian Grün christian.gruen@gmail.com writes:
CG> ..try file:read-text() or file:read-binary(): CG> http://docs.basex.org/wiki/File#file:read-text
They don't work.
The first ruins all brackets it encounters, escaping them.
The latter just returns base64.
There is no way to get the darn file just inserted without mangling.
The first ruins all brackets it encounters, escaping them.
That's what XML serialization is about; everything else would be invalid. Once again, you may want to switch to "text" as output method to avoid escaping:
http://docs.basex.org/wiki/Serialization
Christian
"CG" == Christian Grün christian.gruen@gmail.com writes:
The first ruins all brackets it encounters, escaping them.
CG> That's what XML serialization is about; everything else would be CG> invalid. Once again, you may want to switch to "text" as output method CG> to avoid escaping:
CG> http://docs.basex.org/wiki/Serialization
It is a mixed document.
I just need to import my english.html that is created by txt2html.
I need a way to turn of the mangling.
declare namespace atom='http://www.w3.org/2005/Atom'; declare option db:parser "html"; declare option db:htmlopt "method=html,nons=true"; declare option output:method "html"; declare option output:version "4.01"; declare option output:doctype-public "-//W3C//DTD HTML 4.01//EN"; declare option output:doctype-system "http://www.w3.org/TR/html4/strict.dtd"; declare option output:include-content-type "yes"; <html lang="zh-tw"> <head> <title>jidanni2 YouTube™ 播放清單 playlists</title> </head> <body> {file:read-text("english.html")} <h1> <a href="http://www.youtube.com/user/jidanni2">jidanni2 YouTube™</a> 播放清單 playlists</h1> <ol> <li> <a href="http://www.youtube.com/playlist?list=LLu1NBeZA_KwhPyXJKLAfDsQ">[喜歡的影片 Liked videos]</a> </li> { for $e in doc("playlists.xml")/atom:feed/atom:entry, $t in $e/atom:title/text() where $t ne "testing" order by $t return <li> <a href="{$e/atom:link[@rel="alternate"][@type="text/html"]/@href}">{$t}</a> </li> } </ol> <hr/> <address> <a href="../index.html">積丹尼</a>(<a href= "../index_en.html">Dan Jacobson</a>) </address> <p>Updated {adjust-date-to-timezone(current-date(), ())} 製</p> </body> </html>
Note that XQuery was designed to *always* generate well-formed XML fragments - which is why it's hardly possible to create arbitrary copy-and-pasted results, as one is used to from other scripting languages. If you still want to do so, you will have to resort to the "text" output method, and compose your results via serialize() and numerous string operations. This is of course possible, but it's somewhat contrary to the original paradigm of XML languages, and XQuery may not be the best language for such a use case. ___________________________
On Wed, May 9, 2012 at 8:24 PM, jidanni@jidanni.org wrote:
"CG" == Christian Grün christian.gruen@gmail.com writes:
The first ruins all brackets it encounters, escaping them.
CG> That's what XML serialization is about; everything else would be CG> invalid. Once again, you may want to switch to "text" as output method CG> to avoid escaping:
CG> http://docs.basex.org/wiki/Serialization
It is a mixed document.
I just need to import my english.html that is created by txt2html.
I need a way to turn of the mangling.
declare namespace atom='http://www.w3.org/2005/Atom'; declare option db:parser "html"; declare option db:htmlopt "method=html,nons=true"; declare option output:method "html"; declare option output:version "4.01"; declare option output:doctype-public "-//W3C//DTD HTML 4.01//EN"; declare option output:doctype-system "http://www.w3.org/TR/html4/strict.dtd"; declare option output:include-content-type "yes";
<html lang="zh-tw"> <head> <title>jidanni2 YouTube™ 播放清單 playlists</title> </head> <body> {file:read-text("english.html")} <h1> <a href="http://www.youtube.com/user/jidanni2">jidanni2 YouTube™</a> 播放清單 playlists</h1> <ol> <li> <a href="http://www.youtube.com/playlist?list=LLu1NBeZA_KwhPyXJKLAfDsQ">[喜歡的影片 Liked videos]</a> </li> { for $e in doc("playlists.xml")/atom:feed/atom:entry, $t in $e/atom:title/text() where $t ne "testing" order by $t return <li> <a href="{$e/atom:link[@rel="alternate"][@type="text/html"]/@href}">{$t}</a> </li> } </ol> <hr/> <address> <a href="../index.html">積丹尼</a>(<a href= "../index_en.html">Dan Jacobson</a>) </address> <p>Updated {adjust-date-to-timezone(current-date(), ())} 製</p> </body> </html>
"CG" == Christian Grün christian.gruen@gmail.com writes:
CG> XQuery may not be the best language for such a use case. OK, I put a @@@ marker in a comment to trigger sed to read it in in my Makefile lyrics.html:playlists.xquery playlists.xml english.html basex $< |sed '/@@@/r english.html' > $@ validate $@ w3m -dump $@
basex-talk@mailman.uni-konstanz.de