You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Stanimir Stamenkov <st...@myrealbox.com> on 2004/10/25 14:13:36 UTC
[XML Schema API] XSModel.getComponentsByNamespace() problem
Hello,
I've faced the following problem: The
'XSModel.getComponentsByNamespace()' method simply doesn't work for
me. I've tried pretty simple example:
-----"simple.xsd"
<?xml version="1.0" encoding="US-ASCII" ?>
<xs:schema
xmlns="http://www.geocities.com/stanio/otherthing"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.geocities.com/stanio/otherthing">
<xs:element name="info">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="description"
minOccurs="0" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----"simple.xsd"--
I've set the default namespace for the schema document to match the
'targetNamespace' although I'm not sure I need it (I've tried it
both ways - with and without it).
A call to 'XSModel.getComponents(XSConstants.ELEMENT_DECLARATION)'
returns an 'XSNamedMap' which contains the "info" element
declaration. However if I call:
XSModel.getComponentsByNamespace(XSConstants.ELEMENT_DECLARATION,
"http://www.geocities.com/stanio/otherthing");
I get a 'null' result although the API doc specifies it should
return an empty map even if it didn't find matching element. But the
real problem is that it doesn't find the matching element - "info".
Is this a know issue?
FWIW, If I don't use 'targetNamespace' and try:
XSModel.getComponentsByNamespace(XSConstants.ELEMENT_DECLARATION,
null);
I get a "positive" result.
--
Stanimir
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: [XML Schema API] XSModel.getComponentsByNamespace() problem
Posted by George Cristian Bina <ge...@sync.ro>.
Hi Stanimir,
If I remember correctly the namespace is checked with == instead of
equals on this method. I guess this is fixed in CVS now. A possible
workaround is to keep a reference to the SymbolTable class and pass the
namespace through that before calling getComponentsByNamespace.
Ok, looking up this issue:
---------
CVS commit:3-Jun-2004:mrglavas:
---------
Fixing a bug reported to xerces-j-user by Robert Houben:
http://marc.theaimsgroup.com/?l=xerces-j-user&m=108587697229050&w=2
We were performing reference comparison with the namespace name
passed into getComponentsByNamespace. The XML Schema API does not
constrict users to using internalized strings so we must use equals.
Should also be returning an empty map when a grammar does not exist
for a given namespace instead of null.
Both of these problems are now fixed.
---------
Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Stanimir Stamenkov wrote:
> Hello,
>
> I've faced the following problem: The
> 'XSModel.getComponentsByNamespace()' method simply doesn't work for me.
> I've tried pretty simple example:
>
> -----"simple.xsd"
> <?xml version="1.0" encoding="US-ASCII" ?>
>
> <xs:schema
> xmlns="http://www.geocities.com/stanio/otherthing"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.geocities.com/stanio/otherthing">
>
> <xs:element name="info">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="title" type="xs:string" />
> <xs:element name="description"
> minOccurs="0" type="xs:string" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
> -----"simple.xsd"--
>
> I've set the default namespace for the schema document to match the
> 'targetNamespace' although I'm not sure I need it (I've tried it both
> ways - with and without it).
>
> A call to 'XSModel.getComponents(XSConstants.ELEMENT_DECLARATION)'
> returns an 'XSNamedMap' which contains the "info" element declaration.
> However if I call:
>
> XSModel.getComponentsByNamespace(XSConstants.ELEMENT_DECLARATION,
> "http://www.geocities.com/stanio/otherthing");
>
> I get a 'null' result although the API doc specifies it should return an
> empty map even if it didn't find matching element. But the real problem
> is that it doesn't find the matching element - "info". Is this a know
> issue?
>
> FWIW, If I don't use 'targetNamespace' and try:
>
> XSModel.getComponentsByNamespace(XSConstants.ELEMENT_DECLARATION,
> null);
>
> I get a "positive" result.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org