Title: RE: XSL transform + schema validate

Hi David,

I wasn't aware that the Xerces SAX parser could be used for schema validation too. That's much preferable... I'll have to give that a try.

The two-pass validation approach sounds like a good idea. I was concerned that I wouldn't be able to get the parser to correctly use two different schemas, but schema hints in the XSLT pass should do the trick.

btw, do you know if Xalan-C can be built as a static library? (Linux and Solaris are the platforms that matter for me.) I know that Xerces-C 2.1.0 requires a patch set in order to produce a .a rather than a .so.

- Matt

> -----Original Message-----
> From: David N Bertoni/Cambridge/IBM
> [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, November 23, 2002 3:05 PM
> To: [email protected]
> Subject: Re: XSL transform + schema validate

>
>  Hi Matt,
>
> I don't think there's any magic here:
>
>    1. Use Xalan to perform the transformation to the
> intermediate format,
>    using your stylesheet.
>    2. Write an XML Schema for the intermediate format.
>    3. Parse the XML using one of the Xerces parsers.  I would
> suggest using
>    SAX2XMLReader, unless you have a valid reason to create a
> DOM instance.
>
> If you use a SAX2XMLReader, you can use the setProperty()
> member function
> to set the location for the schema file.  Or, you can simply generate
> schema hints in the XML document you generate with Xalan. The
> defaults for
> SAX2XMLReader are to do validation and to do schema processing, so you
> don't really need to set anything else.
>
> Note that you can also write a schema for your initial input
> document, and
> tell Xalan you want the input document validated before the
> transformation.
> You'll find member functions for this purpose in the class
> XalanTransformer, which is the recommended interface for
> using Xalan.  See:
>
>    XalanTransformer::setUseValidation()
>    XalanTransformer::setExternalSchemaLocation()
>    XalanTransformer::setExternalNoNamespaceSchemaLocation()
>
> There are many Xerces sample applications which illustrate
> how to use the
> parsers.
>
> Hope that helps...
>
> Dave
>
>
>
>                                                              
>                                                              
>          
>                       "Kangas, Matt"                         
>                                                              
>          
>                       <[EMAIL PROTECTED]         To:     
> "Xalan-C-Users (E-mail)" <[email protected]>      
>                
>                       .com>                    cc:      (bcc:
> David N Bertoni/Cambridge/IBM)                               
>          
>                                                Subject: XSL
> transform + schema validate                                  
>            
>                       11/22/2002 04:35                       
>                                                              
>          
>                       PM                                     
>                                                              
>          
>                                                              
>                                                              
>          
>
>
>
> Hello,
>
>
> I'm looking to accomplish the following in a C++ program:
>
>
> XML -> XSLT -> DOM -> Schema validate -> map to data classes
>
>
> In other words,
>
>
> (1) run an XML document through an XSL transformation,
> resulting in a DOM
> tree
> (2) re-parse the DOM tree, applying an XML Schema validation
> in the process
>
> (3) then do something with the result...
>
>
> I want to parse/validate/map an XML document to a set of data classes.
> However, the input XML document's structure does not correspond to my
> program's model, so I want to convert to an intermediary
> format first. I
> would also like to validate the intermediary format
> rigorously, because
> this is more likely to remain the same throughout my app's
> lifecycle than
> the input format.
>
>
> Has anybody achieved this with Xerces-C 2.1.0 and the latest
> Xalan-C? I
> expect that I can figure it out myself, eventually, but if somebody's
> already figured out what magical combination of parser options is
> necessary, I would greatly appreciate a hint or two...
>
>
> Thanks,
> - Matt
>
>
> ----
> matt kangas                                        core development
> hotjobs.com / a Yahoo! service / 917.438.2649 / [EMAIL PROTECTED]
>
>
>

Reply via email to