Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 8th, 2008, 09:49 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
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.

Reply With Quote
  #2 (permalink)  
Old April 8th, 2008, 10:13 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
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 -/
Reply With Quote
  #3 (permalink)  
Old April 8th, 2008, 10:47 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old April 9th, 2008, 01:54 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:25 AM.


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