[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] In XPath 2.0 can my XSLT program validate the input an
Hi Folks, I want my input XML document to be validated within my XSLT program. I don't want the input validated when I invoke the transformation; thus, I do not specify the -val flag when I invoke SAXON. I want to validate non-atomic values (i.e., elements with complexType). I want to test whether the validation succeeded. I want to do this in XPath 2.0. Is it possible? EXAMPLE I have an XML Schema which declares a Book element and a BookType: ------------------------------------------------------------------ <xsd:element name="Book" type="BookType" /> <xsd:complexType name="BookType"> <xsd:sequence> ... </xsd:sequence> </xsd:complexType> ------------------------------------------------------------------ In my XSLT program I import the XML Schema: <xsl:import-schema schema-location="BookStore.xsd"/> In my XSLT program I have a template rule for Book. I want this template rule to validate the Book against the XML Schema and only output the Book if validation succeeds. Here is the code that I used: <xsl:template match="Book"> <xsl:if test="data(.) instance of element(Book, BookType)"> <xsl:sequence select="."/> </xsl:if> </xsl:template> I ran my XSLT program and the output contained no Book elements, even though I know they are valid. Here is what I think the problem is: since I did not specify the SAXON -val flag, the input has no type annotations. Consequently, each Book is not an instance of a Book element with type BookType and this boolean condition fails: data(.) instance of element(Book, BookType) Do I have a correct understanding of what the problem is? Is there a way to solve this problem? Here is what I seek: (1) don't validate the input at invoke time, (2) do validate the input within the XSLT program, and (3) do explicitly check whether validation succeeded. /Roger
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|