Title: Message
Castor-Dev,
 
I'm trying to use SourceGenerator with a schema that contains in the Annotations/Appinfo
tags, for example XSD with Schematron fragments or tagged documentation and I'm receiving
the error described bellow.
 
Is this a bug in the SourceGenerator, or I'm making some mistake ?
Could you help to find a way to compile XSD files that contains some Schematron parts ?
 
Command
java -Djava.ext.dirs=..\lib org.exolab.castor.builder.SourceGenerator -i tournament.xsd
-dest ..\generated_code
Error
org.xml.sax.SAXException: 'sch:title' has not been declared in the XML Schema na
mespace.
   line: 7
        at org.exolab.castor.xml.schema.reader.SaxUnmarshaller.error(SaxUnmarsha
ller.java:169)
        at org.exolab.castor.xml.schema.reader.SchemaUnmarshaller.startElement(S
chemaUnmarshaller.java:299)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXP
arser.java:321)
        at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaVa
lidator.java:401)
        at org.apache.xerces.impl.XMLNamespaceBinder.startElement(XMLNamespaceBi
nder.java:559)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDV
alidator.java:2678)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidat
or.java:782)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElemen
t(XMLDocumentFragmentScannerImpl.java:747)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1445)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XM
LDocumentFragmentScannerImpl.java:328)
        at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardP
arserConfiguration.java:479)
        at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardP
arserConfiguration.java:521)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:148)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.j
ava:972)
        at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenera
tor.java:357)
        at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenera
tor.java:410)
        at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:6
37)
Command
java -Djava.ext.dirs=..\lib org.exolab.castor.builder.SourceGenerator -i CarsXSD.xsd
-dest ..\generated_code
Error
org.xml.sax.SAXException: 'doc:document' has not been declared in the XML Schema
 namespace.
   line: 7
        at org.exolab.castor.xml.schema.reader.SaxUnmarshaller.error(SaxUnmarsha
ller.java:169)
        at org.exolab.castor.xml.schema.reader.SchemaUnmarshaller.startElement(S
chemaUnmarshaller.java:299)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXP
arser.java:321)
        at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Abst
ractXMLDocumentParser.java:209)
        at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaVa
lidator.java:420)
        at org.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBi
nder.java:580)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDV
alidator.java:2675)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidat
or.java:797)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElemen
t(XMLDocumentFragmentScannerImpl.java:743)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1445)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XM
LDocumentFragmentScannerImpl.java:328)
        at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardP
arserConfiguration.java:479)
        at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardP
arserConfiguration.java:521)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:148)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.j
ava:972)
        at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenera
tor.java:357)
        at org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenera
tor.java:410)
        at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:6
37)
 
Regards,
 
Fernando Mattoso Lemos
 IT Director

[EMAIL PROTECTED]

Av. Marginal do Rio Pinheiros, 5200
05693-000  S�o Paulo - SP - Brazil
Phone: +55 11 3759-8212
Fax:     +55 11 3759-8001


www.eversystems.com
 
 
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.3 U (http://www.xmlspy.com) by Fernando (EverSystems) -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
xmlns:doc="./formatter.xsd">
	<xsd:annotation>
		<xsd:appinfo>
			<doc:document format="delimeter"/>
		</xsd:appinfo>
	</xsd:annotation>

	<xsd:element name="doc">
		<xsd:annotation>
			<xsd:documentation>
			Element description
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="owner" type="xsd:string"/>
				<xsd:element name="age" type="xsd:integer"/>
				<xsd:element name="cars" type="CarsType"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:complexType name="CarsType">
		<xsd:sequence>
			<xsd:element name="car" type="CarType" maxOccurs="unbounded"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:complexType name="CarType">

		<xsd:sequence>
			<xsd:element name="factory" type="xsd:string"/>
			<xsd:element name="model" type="xsd:string"/>
		</xsd:sequence>
		<xsd:attribute name="category" use="optional">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="sport"/>
					<xsd:enumeration value="utilitary"/>
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="www.allette.com.au/Tournament" xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns="www.allette.com.au/Tournament" xmlns:sch="http://www.ascc.net/xml/schematron"; elementFormDefault="qualified">
<!-- The namespace declaration xmlns:sch="http://www.ascc.net/xml/schematron"; needs to be added -->
	<xsd:annotation>
		<xsd:appinfo>
			<!-- The first appinfo in the XSD schema contains the Schematron title and namespace declarations -->
			<sch:title>Schematron validation schema for the Tournament</sch:title>
			<sch:ns prefix="t" uri="www.allette.com.au/Tournament"/>
		</xsd:appinfo>
	</xsd:annotation>
	<xsd:element name="Tournament">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="Name" type="xsd:string"/>
				<xsd:element name="Type">
					<xsd:annotation>
						<xsd:appinfo>
							<!-- Each appinfo with schematorn information need to be on the pattern level. -->
							<sch:pattern name="Check participants for single and double matches.">
								<sch:rule context="t:Type[text() = 'Singles']">
									<sch:assert test="../t:Participants/@nbrParticipants >= 2">If you're playing single matches there must be at least 2 participants.</sch:assert>
									<sch:assert test="../t:Participants/@nbrParticipants = ../t:Teams/@nbrTeams">If you're playing single matches the number of participants must equal the number of teams.</sch:assert>
								</sch:rule>
								<sch:rule context="t:Type[text() = 'Doubles']">
									<sch:assert test="../t:Participants/@nbrParticipants >= 4">If you're playing doubles you must have at least 4 participants.</sch:assert>
									<sch:assert test="../t:Participants/@nbrParticipants mod 2 = 0">If you're playing doubles the number of particiapants must be a multiple of 2.</sch:assert>
									<sch:assert test="../t:Participants/@nbrParticipants = ../t:Teams/@nbrTeams * 2">If you're playing doubles the number of participants must equal the number of teams x 2.</sch:assert>
								</sch:rule>
							</sch:pattern>
						</xsd:appinfo>
					</xsd:annotation>
					<xsd:simpleType>
						<xsd:restriction base="xsd:string">
							<xsd:enumeration value="Singles"/>
							<xsd:enumeration value="Doubles"/>
						</xsd:restriction>
					</xsd:simpleType>
				</xsd:element>
				<xsd:element name="Date" type="xsd:date"/>
				<xsd:element ref="Participants"/>
				<xsd:element name="Teams" type="Teams"/>
				<xsd:element name="Matches" type="Matches"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="Participants">
		<xsd:complexType name="Participants">
			<xsd:sequence>
				<xsd:element name="Name" minOccurs="2" maxOccurs="unbounded">
					<xsd:complexType>
						<xsd:simpleContent>
							<xsd:extension base="xsd:string">
								<xsd:attribute name="id" type="xsd:ID" use="required"/>
							</xsd:extension>
						</xsd:simpleContent>
					</xsd:complexType>
				</xsd:element>
			</xsd:sequence>
			<xsd:attribute name="nbrParticipants" type="xsd:positiveInteger" use="required"/>
		</xsd:complexType>
	</xsd:element>
	<xsd:complexType name="Teams">
		<xsd:sequence>
			<xsd:element name="Team" minOccurs="2" maxOccurs="unbounded">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="Member" type="xsd:IDREF" maxOccurs="2"/>
					</xsd:sequence>
					<xsd:attribute name="id" type="xsd:ID" use="required"/>
					<xsd:attribute name="Name" type="xsd:string"/>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
		<xsd:attribute name="nbrTeams" type="xsd:positiveInteger" use="required"/>
	</xsd:complexType>
	<xsd:complexType name="Matches">
		<xsd:sequence>
			<xsd:element name="Match" maxOccurs="unbounded">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="Team" type="xsd:IDREF" minOccurs="2" maxOccurs="2"/>
					</xsd:sequence>
					<xsd:attribute name="id" type="xsd:ID" use="required"/>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
		<xsd:attribute name="nbrMatches" type="xsd:positiveInteger" use="required"/>
	</xsd:complexType>
</xsd:schema>

Reply via email to