Skip to content

Instantly share code, notes, and snippets.

View hou2zi0's full-sized avatar

猴子 hou2zi0

View GitHub Profile
@hou2zi0
hou2zi0 / XSLT-serialization-parameters
Created June 4, 2019 10:18
XSLT-serialization-parameters
<xsl:variable name="serial-params">
<output:serialization-parameters>
<output:omit-xml-declaration value="yes"/>
</output:serialization-parameters>
</xsl:variable>
@hou2zi0
hou2zi0 / Reduce_FODT_to_Simple_XML.xsl
Last active October 4, 2025 12:47
Reduces a FODT-file (Flat Open Document File Format) to a simplified XML-tree. Preserves custom styles and formatting from the Libre Office Document.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
@hou2zi0
hou2zi0 / Test_for_FODT_stylesheet_name.xslt
Last active November 30, 2018 15:41
Takes a flat XML document with implicit structure and transform it into a nested structure. In the example below, the document’s root is <doc>, the element starting each structural record is <head>.
<!--
Tests queries text:p's human understandable style-name for testing in template
-->
<xsl:template match="text:p">
<xsl:variable name="style" select="@text:style-name"/>
<xsl:variable name="name" select="/root()/node()//office:automatic-styles/style:style[@style:name=$style]/@style:parent-style-name"/>
<xsl:choose>
<xsl:when test="$name = 'Separator' or $style = 'Separator'">
</xsl:when>
<xsl:when test="$name = 'Person' or $style = 'Person'">
@hou2zi0
hou2zi0 / split_on_newline_to_paragraphs_and_apply_templates.xsl
Last active October 12, 2018 09:00
XSL-Template for XSLT 3.0 that splits a node’s content on a newline (`\n`) and converts the resulting string array into new paragraphs (`<p>`) while preserving the mixed content within the strings by serializing and parsing, thus enabling the script to apply further `<xsl:apply-templates>` actions.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"
exclude-result-prefixes="xs"
version="3.0">
<xsl:output indent="yes" method="xml"/>
<xsl:mode on-no-match="shallow-copy"/>
@hou2zi0
hou2zi0 / image_upload_memory_leaflet.js
Last active October 5, 2018 14:00
Upload an image into the Browser's memory and process it with Leaflet.js (or maybe some other library, as well).
// Declare a variable to store the image overlay.
let image;
// Get the file input element in the Add event listener to the file upload element (e.g. with the id "file-imput-html-element") in your HTML.
const AddImage = document.getElementById('file-imput-html-element').addEventListener("change", (e) => {
// Set the initial image bounds in the Leaflet.js map.
let bounds = [
[0, 0],
[100, 100]
];