[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT/XQuery polyglot
Polyglot script q.xml does real computation. It evaluates "isXPath1" XPath expression I created based on a longer one from Jonathan Robie. It outputs "false" for XPath 2.0 (Saxon XQuery, Saxon XSLT and DataPower XQuery processor) and "true" for XPath 1.0 (DataPower XSLT processor): Hi, I did some searches but found no other mentioning of this. From https://en.wikipedia.org/wiki/Polyglot_(computing) ... a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it. ... Simple "poly.xml" is a XSLT/XQuery polyglot (same output): $ java net.sf.saxon.Query -q:poly.xml > xq $ java net.sf.saxon.Transform -xsl:poly.xml -s:poly.xml > xsl $ diff xq xsl $ cat xq ; echo <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:template match="/"><xsl:copy-of select="document('')"/></xsl:template></xsl:stylesheet> $ $ cat poly.xml <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:template match="/"><xsl:copy-of select="document('')"/></xsl:template></xsl:stylesheet> $ I found no option to avoid output of xml declaration in Saxon XQuery as command line option. declare option saxon:output "omit-xml-declaration=yes"; would need to stay before output and break XSLT that way. At least the XSLT part would be a cheating quine at most only: https://en.wikipedia.org/wiki/Quine_(computing)#.22Cheating.22_quines Mit besten Gruessen / Best wishes, Hermann Stamm-Wilbrandt Compiler Level 3 support & Fixpack team lead IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃) https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/ https://twitter.com/HermannSW/ https://stamm-wilbrandt.de/GraphvizFiddle/ ---------------------------------------------------------------------- IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|