Category: XPath

  • creating diary entries from my (little) blog articles

    https://codex.wordpress.org/WordPress_Feeds https://codex.wordpress.org/WordPress_Feeds#Finding_Your_Feed_URL 1st approach: xmlstarlet with an XPath expression (rss/channel/item/link) + shell wrapper. 2nd approach: XQuery script looping over rss/channel/item (+ shell wrapper). I am glad to upload it to my github area, in case somebody is interested. Update 2016-08-26: By default WordPress creates an RSS feed with just 10 entries. I don’t create my diary entries…

  • how would I do something like “disable-output-escaping yes” in XQuery?

    http://stackoverflow.com/questions/38677984/how-would-i-do-something-like-disable-output-escaping-yes-in-xquery I am transforming an bank account statement from HTML to a text file (meant to be read by humans) using XQuery. And I want to use “<” and “>” in the output. But XQuery serialisation does the usual XML / HTML escaping. I wonder, how I can get around that unwanted rewriting.

  • XQuery: “declare boundary-space preserve;” does not apply wherever you expect it

    <!– www.bibleserver.com | 522: Connection timed out body{margin:0;padding:0} <!–[if lte IE 9]>/cdn-cgi/scripts/jquery.min.js<![endif]–> /cdn-cgi/scripts/zepto.min.js<!– /cdn-cgi/scripts/cf.common.js Error 522 Ray ID: 3a8c6029598d267e • 2017-10-05 00:48:59 UTC Connection timed out You Browser Working Frankfurt Cloudflare Working www.bibleserver.com Host Error What happened? The initial connection between Cloudflare’s network and the origin web server timed out. As a result, the web…

  • after a couple of months using XPath and xmlstarlet I created my first lenghty XQuery script using Saxon9HE

    “In production” I have been using a Bash+xmlstarlet script, that I wanted to optimise by rewriting it into an XQuery script. This would be my 1st XQuery script after a couple of months of exercising XQuery through Priscilla Walmsley’s book and Saxon9HE – a couple of hours per week only because of my entire workload. During…

  •  XQuery: format-number: using $decimal-format-name is really, really weird

    https://www.w3.org/TR/xpath-functions-30/#func-format-number Can you imagine, that the 3rd argument needs extra double quotes around? And it’s not easy to find an example showing this, but here I found one: https://www.amazon.de/dp/9671317502 – “Web Coding Bible” declare decimal-format local:de decimal-separator = “,” grouping-separator = “.”; declare decimal-format local:en decimal-separator = “.” grouping-separator = “,”; let $numbers := (1234.567, 789,…

  • XQuery: padding an integer or a number, but not with “0”

    I found this function, but it pads on the right: http://www.xqueryfunctions.com/xq/functx_pad-string-to-length.html : functx:pad-string-to-length I derived pad-string-to-length-on-the-left from it: https://github.com/JochenHayek/misc/blob/master/xqueryfunctions/pad-string-to-length-on-the-left.xqy https://github.com/JochenHayek/misc/blob/master/xqueryfunctions I use it around format-integer and format-number, e.g. let $net_amount_formatted := local:pad-string-to-length-on-the-left( format-number( data($invoice/@net_amount) , ‘#,###.#####’ ) , ‘ ‘ , 12 )

  • XPath and XQuery Functions and Operators 3.0: Formatting integers and numbers

    https://www.w3.org/TR/xpath-functions-30 https://www.w3.org/TR/xpath-functions-30/#formatting-integers https://www.w3.org/TR/xpath-functions-30/#formatting-the-number http://www.xqueryfunctions.com/xq/functx_pad-integer-to-length.html http://www.xqueryfunctions.com/xq/functx_pad-string-to-length.html https://github.com/JochenHayek/misc/blob/master/xqueryfunctions https://github.com/JochenHayek/misc/blob/master/xqueryfunctions/pad-string-to-length-on-the-left.xqy I need to pad a decimal number to a given length with leading white space. Looks like there is nothing in the “built-in library”. Looks like there is no functx:pad-integer-to-length as well, but functx:pad-string-to-length looks intriguing – but it only pads on the right. I created a variant, that pads on…

  • XmlStarlet UG on “Studying Structure of XML Document” – “xmlstarlet elements …”

    http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html#idm47077139665568 http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html I really like “xmlstarlet elements …” – but these very nice and useful XPath expressions come without index. So what if you really, really need them with indexes? I am not sure, you can write a general utility, that rewrites these XPath expressions without index into XPath expressions with index, but for my…

  • extract your build steps from a Jenkins CI job to ordinary and “easy to edit” flat files

    Over time Jenkins jobs can grow into something “a little confusing”, in other words: like cancer. The Jenkins developers were thoughtful enough to provide an API to all the data structures, that Jenkins and its jobs operate on, so we are able to export an entire Jenkins job as XML. You certainly do not want…

  • listing a Jenkins CI folder recursively

    https://github.com/JochenHayek/misc – pls find my script here! First I wrote this as a Shell script … calling XMLStarlet resp. SaxonHE (for XPath) and curl (for retrieving the Jenkins details as XML files). $ …/jenkins_find_jobs.sh https://integration.wikimedia.org/ci folder … freeStyleProject … matrixProject … The listing is quite helpful for documentational purposes. I was really proud on my little achievement…