I'm sure that what you want to do is possible, but I'm not sure from your
description exactly what you want to do.
You talk about a "custom-written parser" - what exactly is this parsing?
One approach might be to call Configuration.addSchemaSource() supplying a
SAXSource; this encapsulates an InputSource (that is, a Stream or Reader)
and an XMLReader. Saxon will call the parse() method of the XMLReader (which
need not be a real XML parser), which must then feed the schema document
back to Saxon as a stream of SAX events.
Alternatively you could construct the schema document as any kind of
in-memory tree structure (a native Saxon TinyTree or a DOM, for example),
and supply this to addSchemaSource() - this would copy the tree to a
different representation, but that's not a big overhead.
> -----Original Message-----
> From: saxon-help-bounces@...
> [mailto:saxon-help-bounces@...] On Behalf
> Of Rushforth, Peter
> Sent: 18 September 2008 19:53
> To: saxon-help@...
> Subject: [saxon] sax parser events for a generated schema as
> an alternativeto an .xsd file
> In a custom-written parser, is there any way to direct sax
> events for a schema that is generated on-the-fly (based on
> content discovered in the input source), such that one
> wouldn't have to generate an xsi:schemaLocation attribute
> event with a namespace uri - hint pair? Or even if one did
> generate that, could you programmatically avoid having to
> access the referenced file by sending sax events as an
> alternative to actually creating the xsd file.
> What I mean is I want to generate the schema, and have saxon
> be able to have access to the schema, but I don't want to
> generate an xsd file as a side effect of parsing (for example
> you might not have write access to the location). A
> colleague suggested seeking a programmatic solution along
> these lines, so I'm wondering what the right api way of doing
> this might be, if indeed it were possible.
> Cheers, and thanks,
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge Build the coolest Linux based
> applications with Moblin SDK & win great prizes Grand prize
> is a trip for two to an Open Source event anywhere in the
> world http://moblin-contest.org/redirect.php?banner_id=100&url=/
> saxon-help mailing list archived at
> http://saxon.markmail.org/ saxon-help@...