[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] XSD Validation with XSLT
Subject: RE: [xsl] XSD Validation with XSLT From: Marian Olteanu <mou_softwin@xxxxxxxxx> Date: Fri, 10 Dec 2004 01:37:42 -0800 (PST) |
This topic leads to the question: is there a Schema validator implemented 100% in XSLT? --- Michael Kay <mike@xxxxxxxxxxxx> wrote: > Interesting! XSLT 2.0 takes you some of the way there, but not the whole > way. > > You can validate an individual employee element in XSLT 2.0 like this: > > <xsl:template match="employee"> > <xsl:copy-of select="." validation="strict"/> > </xsl:template> > > but this leaves open the question of what happens if validation fails. > According to the spec, any validation failure is a fatal error. Saxon has a > switch (-vw on the command line) to treat validation failures instead as > warnings. What it does in such cases is to notify the JAXP ErrorListener of > the failure, and insert a comment into the output file to describe the > validation error. It wouldn't be too difficult to go one step further and > call some kind of user hook to attempt a repair - at least in particular > well-defined cases. > > (This needs the schema-aware version of Saxon, of course) > > Michael Kay > http://www.saxonica.com/ > > > -----Original Message----- > > From: Robert Soesemann [mailto:rsoesemann@xxxxxxxxxxx] > > Sent: 10 December 2004 08:42 > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: [xsl] XSD Validation with XSLT > > > > Hello, > > > > I guess my question might seem somewhat strange. The context > > is, that I > > need to bring in content into a CMS that will validate it againts XML > > Schema files. Some of the XML files that I want to import might not > > provide data where the datamodel of the CMS might require this. > > > > My idea was to validate the input against a xsd *by means of XSLT*. > > This would *not need to validate the whole structure but only test > > whether elements with unique names have a value or not. I a required > > field is found to be empty a predefined value should be > > inserted. (e.g. > > a -1 for xs:integer or n/a for xs:string) > > > > To give you an example of my structure: > > XML: > > ---- > > <employee> > > <name>Tom</name> > > <id></id> <-- is required > > <managedBy>Hans<managedBy> <-- is required > > <manages>Frank</manages> > > </employee> > > > > XSD: > > ---- > > <xs:element name="employee"> > > <xs:complexType> > > <xs:choice minOccurs="0" maxOccurs="1"> > > <xs:element name="name" > > type="xs:string"/> > > <xs:element name="id" type="xs:string" > > minOccurs="1"/> > > ... > > > > > > OUTPUT: > > ------- > > <employee> > > <name>Tom</name> > > <id>n/a</id> <-- is required > > <managedBy>Hans<managedBy> <-- is required > > <manages>Frank</manages> > > </employee> > > > > Any help is very welcome. > > > > Robert > > ===== Marian http://www.utdallas.edu/~mgo031000/ __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSD Validation with XSLT, Michael Kay | Thread | Re: [xsl] XSD Validation with XSLT, Colin Paul Adams |
RE: [xsl] XSD Validation with XSLT, Robert Soesemann | Date | Re: [xsl] XSD Validation with XSLT, Colin Paul Adams |
Month |