XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Haseeb HassanSubject: Verifying XML and XSD within XSLT
Author: Haseeb Hassan
Date: 09 Dec 2007 03:44 PM
I have to design an XSLT that verifies an XML file on an specific schema.
like if i have following XSD,

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="language" type="xs:string"/>
<xs:element name="ISBN" type="xs:long"/>
<xs:element name="price" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

and an XML file like,

<?xml version="1.0" encoding="UTF-8"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test1.xsd">

<book>
<title>The World as i see it</title>
<author>ABC</author>
<language>English</language>
<ISBN>123456789</ISBN>
<price>12.99</price>
</book>

<book>
<title>Da Vinci Code</title>
<author>Dan Brown</author>
<language>English</language>
<ISBN>123456789</ISBN>
<price>14.99</price>
</book>

</library>


my XSLT should verify if this XML conforms to the above mentioned schema.
N.B. this schema can be flexible so could be the XML and the XSLT should stand by even in such scenario.


UnknownNoname(37).

Postnext
(Deleted User) Subject: Verifying XML and XSD within XSLT
Author: (Deleted User)
Date: 11 Dec 2007 10:50 AM
Hi,
there is no instruction in XSL to validate a piece of XML; but each processor can optionally validate its input, via specific options. For instance, if you display the Scenario Settings dialog for an XSLT document opened inside Stylus Studio, select Saxon as processor and click on the Settings button, you can specify to use the Schema-aware processor and tell him to perform a Strict source document validation.

Hope this helps,
Alberto

Postnext
Haseeb HassanSubject: Verifying XML and XSD within XSLT
Author: Haseeb Hassan
Date: 12 Dec 2007 05:12 AM
Thanks for that but the thing is that you can not show an output using the depending on the success or failure of XML doc and schema. I need some reference regarding this.

Posttop
(Deleted User) Subject: Verifying XML and XSD within XSLT
Author: (Deleted User)
Date: 12 Dec 2007 11:32 AM
Hi,
this is not possible in normal XSLT 1.0. Even in XSLT 2.0 and XQuery 1.0 (that support the concept of validating arbitrary nodes) a failed validation would stop the processing with a runtime error.
The only choice left would be writing inside Stylus Studio a pipeline that contains a Validate node followed by two XSLT nodes, one being executed when the document is valid and one when the document is invalid.

Hope this helps,
Alberto

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.