saxon

Convert JSON to XML using XSLT 3.0 - escape ampersand in element key

旧时模样 提交于 2020-01-25 10:49:08
问题 Usign XSLT we wish to transform the JSON to XML : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs math" version="3.0"> <xsl:output indent="yes" /> <xsl:template match="data"> <xsl:copy-of select="json-to-xml(.)" /> </xsl:template> </xsl:stylesheet> We have follwing JSON output from Microsoft Dynamics 365 that

Saxon XSLT Transformation: How to close outputstream when failing during transformation

☆樱花仙子☆ 提交于 2020-01-22 02:33:08
问题 I want to do a XSLT transformation with multiple output files. There for I used "xsl:result-document". When the transformation fails, all output files should be deleted. But if the generation of a document created by "xsl:result-document" fails, my program not able to delete this document anymore. I think the reason is, that "xsl:result-document" create a different OutputStream. Does anyone know how to close all output streams? Edit: I use Saxon 9.5 to do the transformation. Please see below

xslt 3.0 json-to-xml and xml-to-json conversion

吃可爱长大的小学妹 提交于 2020-01-21 03:49:26
问题 Currently I need to convert json to xml and xml to json vice versa using XSLT 3.0 & Saxon-HE. Below is my json abc.xml file <?xml version="1.0" encoding="UTF-8" ?> <root> <data>{ "cars" : [ {"doors" : "4","price" : "6L"}, {"doors" : "5","price" : "13L"} ] } </data> </root> Below is xsl file xyz.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs

XSLT: CSV (or Flat File, or Plain Text) to XML

痴心易碎 提交于 2020-01-13 19:00:48
问题 I am trying to convert plain text files to XML files using XSLT. I started with CSV files, because that is a well-known file format that I could start Googling examples on. I stumbled onto this: http://ajwelch.blogspot.com/2007/02/csv-to-xml-converter-in-xslt-20.html, which also points at http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html. Those links contain what is, supposedly, an XSLT (2.0) that can take a CSV file and convert it to an XML file. ...Except it doesn't actually work. I

How to use saxon built-in catalog feature

别来无恙 提交于 2020-01-11 10:35:29
问题 I downloaded SaxonHE9-4-0-6J and want to process XHTML on CLI. However Saxon tries to load DTD from W3C and it takes too much time for every simple command. I have xml catalog, which I use successfully with xmllint by set env variable pointing to catalog file, but I have no idea how to make Saxon use it. Google reveals whole history of changes (thus confusion) in regards of using catalogs with Saxon, and none made me happy. I downloaded resolver.jar and set it in my CLASSPATH, but I can't

Pass xml document as parameter to xsl

余生颓废 提交于 2020-01-11 09:53:50
问题 I have read a lot of post and tried a lot of things but still can't get the xsl to find values in the parameter. I started with java's sun xalan and never got it working so I switched to saxon to no avail. I want to combine two xml docs into one with xls. Never are on a file system, this is for a web app that builds xml strings/ docs. I have tried passing an DTMAxisIterator, DomSource , Doc to Node set in xsl, string. It worked fine in NotePad++ with an xsl document() but I don't want to save

XSLT change/override attribute on copy-of not applied (using saxon )

杀马特。学长 韩版系。学妹 提交于 2020-01-06 12:26:10
问题 I have a xslt like this: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:db="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <xsl:for-each select="db:databaseChangeLog/db:changeSet"> <xsl:if test="name(*[1])='createTable'"> <xsl:result-document href="base/tables/{position()}_{name(*[1])}_{*[1]/@tableName}.xml"> <databaseChangeLog xmlns="http://www

Saxon XSLT-Transformation: How to change serialization of an empty tag from <x/> to <x></x>?

混江龙づ霸主 提交于 2020-01-06 08:16:31
问题 I do some XSLT-Transformation using Saxon HE 9.2 with the output later being unmarshalled by Castor 1.3.1 . The whole thing runs with Java at the JDK 6 . My XSLT-Transformation looks like this: <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://my/own/custom/namespace/for/the/target/document"> <xsl:output method="xml" encoding="UTF-8" indent="no" /> <xsl:template match="/"> <ns:item> <ns:property name="id"> <xsl:value-of select="/some/complicated

Saxon XSLT-Transformation: How to change serialization of an empty tag from <x/> to <x></x>?

随声附和 提交于 2020-01-06 08:16:12
问题 I do some XSLT-Transformation using Saxon HE 9.2 with the output later being unmarshalled by Castor 1.3.1 . The whole thing runs with Java at the JDK 6 . My XSLT-Transformation looks like this: <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://my/own/custom/namespace/for/the/target/document"> <xsl:output method="xml" encoding="UTF-8" indent="no" /> <xsl:template match="/"> <ns:item> <ns:property name="id"> <xsl:value-of select="/some/complicated

how to extract an XPATH from an html page with Saxon-PE commandline

随声附和 提交于 2020-01-06 08:14:33
问题 I would like to extract the XPATH //DIV[@id="ps-content"] out from this web page: http://www.amazon.com/dp/1449319432 (saved as a local file) I would like to do it with a single line of command-line with one of the best parsers, like Saxon-PE or BaseX. So far the shortest solution that I (seemed to have) found is with these two lines: java -jar tagsoup-1.2.1.jar <page.html >page.xhtml" java -cp saxon9pe.jar net.sf.saxon.Query -s:"page.xhtml" -qs:"//DIV[@id='ps-content']" but all what it