You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Sibon Barman <si...@ss8.com> on 2001/03/12 21:38:05 UTC

schema validation problem in xerces 1.3.0

I am having problem in validating a xml document with xml schema using
xerces 1.3.0:

Here is the xml document:
<ui-look-and-feel xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
  	          xsi:noNamespaceSchemaLocation="uilfparam.xsd">
	<default-font>
		<font name="SansSerif" style="plain" size="12"/>
	</default-font>

	<default-title-font>
		<font name="Dialog" style="bold" size="12" />
	</default-title-font>

</ui-look-and-feel>

Here is the xml schema:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2000/10/XMLSchema">
   <element name="ui-look-and-feel" type="RootElemType" />

   <complexType name="FontType" content="empty">
	<attribute name="name" type="string" minOccurs="1" />
	<attribute name="style" minOccurs="1">
	     <simpleType base="string">
	         <enumeration value="plain" />
		 <enumeration value="bold" />
		 <enumeration value="italic" />
	     </simpleType>
	</attribute>
        <attribute name="size" type="positiveInteger" minOccurs="1" />
    </complexType>
    
    <complexType name="DefaultType">
	<element name="font" type="FontType" />
    </complexType>

    <complexType name="UIConstantType">
	<element name="font" type="FontType" minOccurs="0"/>
    </complexType>

 
    <complexType name="RootElemType">
	<element name="default-font" type="DefaultType" minOccurs="0" />
	<element name="default-title-font" type="DefaultType" minOccurs="0"
/>
	<element name="ui-constant" type="UIConstantType" minOccurs="0"
maxOccurs="*"/>
    </complexType>
</schema>
	
Here is the piece of code that deals with the schema:
	//Xerces 1.3
            DOMParser parser = new DOMParser();
            parser.setErrorHandler(new UISAXEventHandler());
 
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
            parser.setFeature("http://xml.org/sax/features/validation",
true);
 
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
true);
            parser.parse(filename);
	//JDOM
            DOMBuilder builder = new DOMBuilder(ADAPTER_CLASS);
            Document doc = builder.build(parser.getDocument());

I get the following error when I run  the application :

[Error] uilfparam.xml:27:60: Element type "ui-look-and-feel" must be
declared.

I couldn't figure out the problem ---- can anybody see where this problem
could be coming from?

Cheers,
Sibon Barman
SS8 Networks, Inc.
Suite 500
495 March Road, Kanata, 
Ontario K2K 3G1

*: (613)592-2100 ext:3281
*: sibon@ss8.com



RE: schema validation problem in xerces 1.3.0

Posted by "Derek Hachey (UNB)" <v1...@unb.ca>.
As an added complexity, I am looking to build a repository system for my XML
documents and XML Schemas (and eventually XSLT documents as well), but I
want to know if there is a way to associate a stream (or string)
representing an XML Document with another stream (or string) representing an
XML Schema when using the DOMParser.  Basically, I am not dealing with
files, which is the conventional way to deal with XML Documents and XML
Schemas, and I want to parse an XML Document and validate it against an XML
Schema.

Regards,

Derek

-----Original Message-----
From: rasco rasco [mailto:ocsar73@yahoo.it]
Sent: March 15, 2001 00:59
To: xerces-j-user@xml.apache.org
Subject: Re: schema validation problem in xerces 1.3.0



--- Sibon Barman <si...@ss8.com> ha scritto: > I am
having problem in validating a xml document
> with xml schema using
> xerces 1.3.0:
>
> Here is the xml document:
> <ui-look-and-feel
>
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
>
> xsi:noNamespaceSchemaLocation="uilfparam.xsd">
> 	<default-font>
> 		<font name="SansSerif" style="plain" size="12"/>
> 	</default-font>
>
> 	<default-title-font>
> 		<font name="Dialog" style="bold" size="12" />
> 	</default-title-font>
>
> </ui-look-and-feel>
>
> Here is the xml schema:
> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
>    <element name="ui-look-and-feel"
> type="RootElemType" />
>
>    <complexType name="FontType" content="empty">
> 	<attribute name="name" type="string" minOccurs="1"
> />
> 	<attribute name="style" minOccurs="1">
> 	     <simpleType base="string">
> 	         <enumeration value="plain" />
> 		 <enumeration value="bold" />
> 		 <enumeration value="italic" />
> 	     </simpleType>
> 	</attribute>
>         <attribute name="size"
> type="positiveInteger" minOccurs="1" />
>     </complexType>
>
>     <complexType name="DefaultType">
> 	<element name="font" type="FontType" />
>     </complexType>
>
>     <complexType name="UIConstantType">
> 	<element name="font" type="FontType"
> minOccurs="0"/>
>     </complexType>
>
>
>     <complexType name="RootElemType">
> 	<element name="default-font" type="DefaultType"
> minOccurs="0" />
> 	<element name="default-title-font"
> type="DefaultType" minOccurs="0"
> />
> 	<element name="ui-constant" type="UIConstantType"
> minOccurs="0"
> maxOccurs="*"/>
>     </complexType>
> </schema>
>
> Here is the piece of code that deals with the
> schema:
> 	//Xerces 1.3
>             DOMParser parser = new DOMParser();
>             parser.setErrorHandler(new
> UISAXEventHandler());
>
>
parser.setFeature("http://apache.org/xml/features/validation/schema",
> true);
>
>
parser.setFeature("http://xml.org/sax/features/validation",
> true);
>
>
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
> true);
>             parser.parse(filename);
> 	//JDOM
>             DOMBuilder builder = new
> DOMBuilder(ADAPTER_CLASS);
>             Document doc =
> builder.build(parser.getDocument());
>
> I get the following error when I run  the
> application :
>
> [Error] uilfparam.xml:27:60: Element type
> "ui-look-and-feel" must be
> declared.
>
> I couldn't figure out the problem ---- can anybody
> see where this problem
> could be coming from?

Try :
     <complexType name="DefaultType">
----->	<sequence>
 	<element name="font" type="FontType" />
----->  </sequence>
     </complexType>

for all the type definition but the FontType type.
I used SAXParser and works well.
bye.

______________________________________________________________________
Do You Yahoo!?
Il tuo indirizzo gratis e per sempre @yahoo.it su http://mail.yahoo.it

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: schema validation problem in xerces 1.3.0

Posted by rasco rasco <oc...@yahoo.it>.
--- Sibon Barman <si...@ss8.com> ha scritto: > I am
having problem in validating a xml document
> with xml schema using
> xerces 1.3.0:
> 
> Here is the xml document:
> <ui-look-and-feel
>
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
>   	         
> xsi:noNamespaceSchemaLocation="uilfparam.xsd">
> 	<default-font>
> 		<font name="SansSerif" style="plain" size="12"/>
> 	</default-font>
> 
> 	<default-title-font>
> 		<font name="Dialog" style="bold" size="12" />
> 	</default-title-font>
> 
> </ui-look-and-feel>
> 
> Here is the xml schema:
> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
>    <element name="ui-look-and-feel"
> type="RootElemType" />
> 
>    <complexType name="FontType" content="empty">
> 	<attribute name="name" type="string" minOccurs="1"
> />
> 	<attribute name="style" minOccurs="1">
> 	     <simpleType base="string">
> 	         <enumeration value="plain" />
> 		 <enumeration value="bold" />
> 		 <enumeration value="italic" />
> 	     </simpleType>
> 	</attribute>
>         <attribute name="size"
> type="positiveInteger" minOccurs="1" />
>     </complexType>
>     
>     <complexType name="DefaultType">
> 	<element name="font" type="FontType" />
>     </complexType>
> 
>     <complexType name="UIConstantType">
> 	<element name="font" type="FontType"
> minOccurs="0"/>
>     </complexType>
> 
>  
>     <complexType name="RootElemType">
> 	<element name="default-font" type="DefaultType"
> minOccurs="0" />
> 	<element name="default-title-font"
> type="DefaultType" minOccurs="0"
> />
> 	<element name="ui-constant" type="UIConstantType"
> minOccurs="0"
> maxOccurs="*"/>
>     </complexType>
> </schema>
> 	
> Here is the piece of code that deals with the
> schema:
> 	//Xerces 1.3
>             DOMParser parser = new DOMParser();
>             parser.setErrorHandler(new
> UISAXEventHandler());
>  
>
parser.setFeature("http://apache.org/xml/features/validation/schema",
> true);
>            
>
parser.setFeature("http://xml.org/sax/features/validation",
> true);
>  
>
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
> true);
>             parser.parse(filename);
> 	//JDOM
>             DOMBuilder builder = new
> DOMBuilder(ADAPTER_CLASS);
>             Document doc =
> builder.build(parser.getDocument());
> 
> I get the following error when I run  the
> application :
> 
> [Error] uilfparam.xml:27:60: Element type
> "ui-look-and-feel" must be
> declared.
> 
> I couldn't figure out the problem ---- can anybody
> see where this problem
> could be coming from?

Try :
     <complexType name="DefaultType">
----->	<sequence>
 	<element name="font" type="FontType" />
----->  </sequence>
     </complexType>

for all the type definition but the FontType type.
I used SAXParser and works well.
bye.

______________________________________________________________________
Do You Yahoo!?
Il tuo indirizzo gratis e per sempre @yahoo.it su http://mail.yahoo.it

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Validation error with fixed attributes

Posted by Norman Walsh <nd...@nwalsh.com>.
Using the latest Xerces (Xerces1, I believe) out of CVS, the following
document is report as invalid:

test.xml:

<!DOCTYPE doc SYSTEM "doc.dtd">
<doc>
<test/>
</doc>

doc.dtd:

<!ELEMENT doc (test+)>

<!ENTITY % simple-xlink.att
        'xmlns:xlink            CDATA   #FIXED
                                        "http://www.w3.org/1999/xlink"
        xlink:type              CDATA   #FIXED "simple" '>

<!ELEMENT test EMPTY>
<!ATTLIST test
	%simple-xlink.att;
>

Xerces reports:

Error:test.xml:3:Undeclared prefix: "xlink:type".

                                        Be seeing you,
                                          norm

-- 
Norman.Walsh@East.Sun.COM    | A man should have any number of little
XML Standards Engineer       | aims about which he should be conscious
Technology Development Group | and for which he should have names, but
Sun Microsystems, Inc.       | he should have neither name for, nor
                             | consciousness concerning, the main aim
                             | of his life.--Samuel Butler (II)

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org