Skip to content

Instantly share code, notes, and snippets.

@tvnpraveen
tvnpraveen / xml2json.xqy
Last active July 7, 2017 16:43
XML to JSON Conversion query
xquery version "1.0-ml";
(:~ This library is a simple XML to JSON conversion utility.
: ****This library does not support attributes in XML
:
:
:)
module namespace xml2json = "http://lib/utils/xml2json";
import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
@tvnpraveen
tvnpraveen / xmlCompare.xqy
Last active December 21, 2016 22:22
XML Comparison Library
module namespace xmlCompare = "http://lib/utils/xmlCompare";
declare variable $xml1 := ();
declare variable $xml2 := ();
declare variable $idReference := ();
declare variable $resultMap := map:map();
@tvnpraveen
tvnpraveen / XSD2SampleXML.xqy
Created June 19, 2017 17:27
XSD to sample XML generator. Does not have attribute support
xquery version "1.0-ml";
import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
declare namespace xsd="http://www.w3.org/2001/XMLSchema";
(: Provide the physical location where all the XSDs exist in $fileLoc :)
declare variable $fileLoc := "/reporting/xsd/”;
(: Provide the main XSD file :)
declare variable $mainXSDFile := "test.xsd";
declare variable $elementMap := map:map();
xquery version "1.0-ml";
module namespace json = "http://lib/utils/compare-json";
declare variable $json-node-1 := ();
declare variable $json-node-2 := ();
declare variable $diff-map := map:map();
(:~ This is a recursive function to compare and update the differences to the map