views:

525

answers:

3

I have a XSLT 1.0 file to transform a XML file using XSLT 1.0. It works fine with IE 6.0, Firefox 3.0.11. However, PHP 5.2.6 XSL XSLTProcessor (providing XSLT 1.0) and Qt C++ QXmlQuery (providing only XSLT 2.0) give blank output.

I'm thinking of 2 ways:

  1. Convert it to XSLT 2.0

  2. Extract Firefox part to parse.

I prefer the 1st one. Please kindly advise how can I do it. The W3C specs seem to long for me to digest and the documents to transform are not that large. Thank you in advance!

+1  A: 

If the whole spec is too long (???), start with the Changes section.

Also, XSLTProcessor is just a wrapper round libxslt, and unlikely to break on a valid XSLT 1.0 transform. I wonder if there is something funky about your transformation that you can fix without going to 2.0, or if there's something wrong with your XSLTProcessor deployment. Can you successfully apply other transformations?

ykaganovich
Thank you for the reply. I use XPath in matching tags. I tried with IE and Firefox, they worked but none work with other tools as I mentioned. I'm trying the W3School tool to adjust. So far it doesn't work.
Viet
@Viet: My guess is also that you are doing something wrong. Apart from the fact that XSLT 2.0 processors execute 1.0 code just fine, I think your time is better spent finding the error, instead of reading XSLT 2.0 spec.
Tomalak
I found that the Tidy converted HTML not into strict XML so XSLT parpsers I listed don't give output. I use Mozilla nsIXSLTProcessor instead. The HTML input is not controlled by me so I can do nothing with it. Thanks anyway.
Viet
@Viet: there is an option in tidy that *will* make it output well-formed XML.
Tomalak
Which one? I need strictly well-formed XML. Thank you.
Viet
Here u go:Processing directives---------------------... -xml specify the input is well formed XML -asxml, -asxhtml convert HTML to well formed XHTML -ashtml force XHTML to well formed HTML -access <level> do additional accessibility checks (<level> = 0, 1, 2, 3). 0 is assumed if <level> is missing.No option to produce strictly well-formed XML.
Viet
XHTML is well-formed XML
ykaganovich
@Tomalak: So silent? Please tell me how to use XML to give well-formed XML output. Thanks.
Viet
+2  A: 

XSLT should be pretty much backward compatibly, although obviously there are things you can use in XSLT 2.0 that make life much easier.

It sounds like you have something wrong in your XSLT, but as you don't provide anything for us to look at it is hard to say.

I would recommend getting hold of Kernow-for-Saxon - it is a great UI for testing XSLT (much better than trying to use Firefox or IE) and if you have errors in your XSLT then Saxon is one of the better XSLT processors for giving good errors to try to identify the cause.

http://kernowforsaxon.sourceforge.net/

I don't know anything about either the PHP or Qt processors, but it is possible there are errors in them that are not handling your XSLT correctly.

samjudson
Hi samjudson, I will upload later today both XML and XSLT files so that you could check. Thank you!
Viet
A: 

After much of hardwork and painful testing, I found the answer myself:

  1. A valid XSLT 1.0 file is also a valid XSLT 1.0 file
  2. PHP and Qt C++ failed as I had <html xslmn="..."> instead of just <html> (which IE & FF were able to transform successfully). For simplicity, I removed <!DOCTYPE and <attributes of the <html> tag.

Thanks everyone for participating in the discussion.

Viet
There is a problem with your first comment .. Please correct it ..
infant programmer