Where do I get test-stylesheets to be able to use xsltproc? - unit-testing

I'm little lost here. I'm using googltest framework and just want to transform the xml report to an html. I found that xsltproc does the job:
xsltproc style.xsl report.xml -o report.hmtl
but first I need to get a stylesheet. Just a basic-generic stylesheet so the result can be visualized on a browser, where can I find it?

Firstly, you've tagged this XSLT 2.0, but xsltproc only supports XSLT 1.0.
Secondly, without knowing what flavour of XML is in report.xml, there isn't really very much one can do by way of a useful generic transformation to HTML. There are attempts like this one:
Generic XSLT to tabluate XML
but whether it produces results that work for you depend entirely on your input and desired output, which you haven't told us anything about.

Related

Running eXist-db XQuery in Saxon

What is the recommended way in Saxon to load in an XML document from eXist-db via XQuery GET/POST within an XSL stylesheet? I want to run an XQL query in eXist-db, which should be simple enough to do as a GET with <xsl:variable name="test" select="doc('xmldb:exist:///db/test.xql')"/> or <xsl:variable name="test" select="doc('http://localhost:8080/exist/rest/db/test.xql')"/>. But the former doesn't exectute the query and tries to return the XQL source as XML, and the latter doesn't have the basic authentication to execute. Also, I really want to send an XML fragment using POST, and have the XQL use that posted XML fragment.
I can't find anything in the Saxon documentation about this. I did find an old EXPath article at http://expath.org/modules/http-client/samples, but the downloads there are 7 years old, and may not work with modern Saxon. So looking for the best known method to do this.
The first thing that comes to mind is the EXPath HTTP Client module. There's no way to persuade the doc() or document() functions to do POST instead of GET, AFAIK.

XSLT Regex Replace Function

We've been pulling our hair out just trying to just trying to get a basic example of the XSLT replace function to work.
I'm leaving this text in tact for context, but you may want to skip to the update
We're using Mirth to pull in HL7 messages. We're unsure whether this supports XSLT version 2, but we believe it uses SAXON - http://saxon.sourceforge.net/, which purportedly does support XSLT2 and hence the replace function.
In any case, we tried using XSLTCake to try and get even a demo replacement to work, to no avail. We've seen this either referenced as replace or fn:replace as well as a couple other suggestions using other libraries.
If XSLT2 isn't supported by Mirth, we would need a workaround for XSLT1. We found one here: XSLT string replace - but have been unable to get this to work either.
This is a tough to get down to a single question as I'm asking alot, but here goes... Can anyone provide a working example of performing a regex replacement in an XSLT? Preferably one that will run in an online parser for reference.
Here's a sample - which apparently should work.1
Update
Thanks to Michael Kay for providing code below to determine XSLT version.
<!--Transformed using 1.0 provided by Apache Software Foundation (Xalan XSLTC)-->
So It turns out we were all wrong about Mirth using SAXON and hence supporting XSLT2. I'll update with our attempt at implementing the version 1 workaround.
First find out which XSLT processor you are using. This is straightforward: insert this
<xsl:comment>Transformed using <xsl:value-of select="system-property('xsl:version')"/> provided by <xsl:value-of select="system-property('xsl:vendor')"/></xsl:comment>
into your stylesheet to output a comment in your result document.
Once you know what programming language you are using, you can start thinking about writing code.

DTD validation before XSLT transformation

I have to write an XSLT to convert a XML file into another XML file. The original input file has to valid with respect to a DTD. Is there a way in which XSLT can validate the input xml file against the DTD before converting it ? Also reject the input file if it does not conform to the DTD.
Also , I will run the XSLT in a tool like Oxygen XML Editor.
Thanks in advance.
JK
You have to do this through your XSLT processor. I don't think there is a way to do this in XSLT itself.
In oXygen, you can go to "XML / XSLT-FO-XQuery / XSLT / Saxon / Saxon-HE/PE/EE" in Preferences and turn DTD validation on or off (there is a combo box).
Not with builtin XSLT-1.0 functions (which cannot detect non-well-formedness in a clean manner either). Your environment may be able to provide this through other tools such as DOM Builders.
This depends entirely on the tool you are using. In this case, this is a question about the Oxygen editor. There's nothing in the specification for XSLT that requires a processor to perform DTD validation when reading XML.

Which is more prefered to be called, "XSL file" or "XSLT file"?

What should I call my file containing XSL code (XSLT code?),
which one sounds more sensible/meaningful.
I know the abbreviation of both of them. But don't know which one to use and where ..
I just now came across these words in w3schools.com
It started with XSL and ended up with
XSLT, XPath, and XSL-FO.
and also saw written "XSL Source code", So what about .. Alejandro's comments .. ?
Now my question reduces to yet more simple version..
Can we call XSLT code as XSL code too? or is it deprecated?
To be nitpicker, I believe XSL is the language and XSLT is a transformation (a piece of code that is written in XSL to transform one XML to another).
So when you're talking of particular pieces of code I think XSLT is more appropriate (just XSLT not XSLT codes), like apha XSLT or so. But when you are talking about language, it should be XSL e.g. XSL skills, XSL code.
This is not only a matter of opinion: just look and see how many questions are in the xslt tag (2299) and how many are in xsl (753) -- the result is clear, isn't it? :)
Related to this in 2010 I proposed that the xsl tag be considered a synonim for the xslt tag. This proposal was voted and approved.
From http://www.w3.org/TR/xslt#section-Introduction
A transformation expressed in XSLT is
called a stylesheet
From http://www.w3.org/TR/xslt20/#what-is-xslt
[Definition: A transformation in the
XSLT language is expressed in the form
of a stylesheet, whose syntax is
well-formed XML [XML 1.0] conforming
to the Namespaces in XML
Recommendation [Namespaces in XML
1.0].]
Leaving aside the formality of the specification, you can call it what you will. With respect to the components of the stylesheet (or transformation): for XSLT 1.0 they are instructions and its contents are templates, for XSLT 2.0 they are declarations and instructions and its contents are sequence constructors
There is no appreciable difference. I use them interchangeably, and so do most people.
Really, does it matter? I'm all for correct terminology, because it usually matters in IT, but in this case you really won't confuse anyone whichever one you use.

what is the best way to write xslt -fo out of xsl+xml

i have complex xslt that formats xml to html
now i need to be able to create xsl fo out of it
what is the best way to do it ?
Here is some ineresting article for you
http://www-128.ibm.com/developerworks/library/x-xslfo2app/
Also you can try next library (I dont't remember, probably it can creat fo files from xslt+xml):
http://www.codeproject.com/KB/dotnet/nfop.aspx
I had a similar requirement, and I did some research, but didn't find a reliable XHTML to FO transformer. There may be one, but there comes a point in some web searches when you have to give up and roll your own.
Instead I took the XML to HTML transformer I had already written and changed it to output FO.
This is a much simpler proposition that a full blown XHTML to FO transformer.
Whilst your details will differ, most structures in HTML have analogues in FO, so you can normally decide what FO construct to use in replacing HTML in your transform fairly easily.
I did this incrementally. If you start with the transform producing the outline of an FO document, and most of your XML being ignored in the transform, you can then build up the output in a measured fashion.