Skip to content

Instantly share code, notes, and snippets.

View fgeorges's full-sized avatar

Florent Georges fgeorges

View GitHub Profile
public class SaxToDom
{
public SaxToDom(XMLReader reader, InputSource input) {
myReader = reader;
myInput = input;
}
public Document makeDom() {
Document doc = null;
try {
declare function local:add-ns-node(
$elem as element(),
$prefix as xs:string,
$ns-uri as xs:string
) as element()
{
element { QName($ns-uri, concat($prefix, ":x")) }{ $elem }/*
};
local:add-ns-node(<xxx><a/></xxx>, "p1", "uri2")
<?xml version="1.0" encoding="UTF-8"?>
<xxx xmlns:p1="uri2">
<a/>
</xxx>
@fgeorges
fgeorges / log-excerpt.txt
Created February 21, 2016 13:50
Add a trigger with MarkLogic
Log excerpt after creation of a new document "/test/hello-world.xml":
2015-10-29 16:18:39.687 Info: expath-console: ***** Document /test/hello-world.xml was created. *****
2015-10-29 16:18:39.687 Info: expath-console: <?xml version="1.0" encoding="UTF-8"?>
2015-10-29 16:18:39.687 Info: expath-console: <hello>World!</hello>
2015-10-29 16:18:39.687 Info: expath-console: *****
@fgeorges
fgeorges / 01-repro.xquery
Last active March 30, 2016 10:35
XQuery parser stack overflow
import module namespace p = "XQueryML30"
at "XQueryML30.xquery";
declare variable $src :=
'
(:~
: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
: mauris ante, commodo sed ipsum et, malesuada blandit neque. Nulla
: nulla neque, malesuada quis dignissim in, hendrerit non
: lorem. Vestibulum in diam venenatis, semper lectus vel, finibus
@fgeorges
fgeorges / README.md
Last active July 19, 2016 06:36
Book icon in Markdown

Intro

  • icon Ⓖ
  • super icon
  • title
  • icon ⧗
  • super icon
  • title
  • icon ⛿
  • super icon
#!/usr/local/bin/phantomjs
var page = require('webpage').create();
var system = require('system');
// ***** Argument handling
function isInt(value) {
return !isNaN(value) &&
parseInt(Number(value)) == value &&
@fgeorges
fgeorges / recursive-descent-copy.xquery
Created December 15, 2018 18:09
XQuery recursive descent copy
(:~
: Template for the recursive descent copy.
:
: This function does not actually modify anything as such. Modify it as needed,
: this version does by default, for each node, a recursive exact same copy.
:
: Note that in addition to typeswitch cases, you can also have regular if/else
: statements, for more complex conditions, but conditions that can be expressed
: as typeswitch cases will be more efficient.
:)