Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2008, 09:49 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validation of all possible results of XSL transfor

Hallo ladies and gentlemen,

I spent a lot of time trying to find existing solution for very simple and in my opinion common task – validate XSL files that transform XML to XML. It's needed to be sure that all variants of transformed XML files will be valid (because there are a lot of variants of input data so there are a lot of variants of output data).

The idea has 2 steps.

The first step is to get the list of input XPaths from XSL (XPaths from input XML which are used in transformation process) and list of output XPaths from XSL (XPaths from output XML which are created in transformation process).

The second step is validation XPaths from input XML (that can be based on XSD of input XML) and validation XPaths from output XML (that can be based on XSD of output XML).

Thanks in advance,

Sergey.

 
Old April 8th, 2008, 10:13 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The best way of doing this by far is to use Schema Validation. This is a new feature of XSLT 2.0 where you basically define a schema that the output must match.

This obviously could be done manually in a pipeline process, to validate the input and output against schemas.

I wouldn't recommend trying to process the XSLT file itself to 'guess' what the output might look like. Perhaps simply create a test suite of input XML to give you some form of test coverage might be a better way to go.

Sam

/- Sam Judson : Wrox Technical Editor -/
 
Old April 8th, 2008, 10:47 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you use schema-aware XSLT 2.0 then you have the potential for the XSLT processor to do this kind of checking. However, some points:

(a) the processor isn't obliged to do compile-time checking in the way you describe. Saxon does a certain amount, Altova as far as I can see only does run-time checking.

(b) Saxon won't give you errors unless you are careful to declare your types in suitable places. For example, if you write a template rule with match="schema-element(invoice)" and then use the path billTo-address/postcode then it will be able to tell you whether this is a legitimate path. However if you just use match="invoice", then all paths are legitimate, because your template rule can match invalid invoices as well as valid ones.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 9th, 2008, 01:54 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply.

So as I understand there isn't the way to do the validation based on XSLT functionality.

So it will be Java solution.

Thank you,

Sergey






Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Edit Query Results in Results Grid druid2112 SQL Server 2005 1 June 28th, 2007 08:49 AM
xsl template, next result or next 10 results ge_or_gi XSLT 8 April 2nd, 2007 07:01 AM
Translating a XML with XSL and saving results DevOne XML 1 April 9th, 2005 07:32 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.