[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-j-user
Subject:    Re: xmlvalidator does not detect violations of uniqueness
From:       Michael_Mcdonough () aigtrading ! com
Date:       2002-08-26 22:38:50
[Download RAW message or body]


Sure does, and thanks.



                                                                                      \
                
                      neilg@ca.ibm.com                                                \
                
                                               To:       xerces-j-user@xml.apache.org \
                
                      08/26/2002 05:10         cc:                                    \
                
                      PM                       Subject:  Re: xmlvalidator does not \
                detect violations of uniqueness                 
                      Please respond to                                               \
                
                      xerces-j-user                                                   \
                
                                                                                      \
                
                                                                                      \





Hi Michael,

This is part of the XPath 1.0 recommendation.  From [1]:

[[
A
QName
in the node test is expanded into an
expanded-name
using the namespace declarations from the expression context. This is the
same way expansion is done for element type names in start and end-tags
except
that the default namespace declared with xmlns is not used: if the
QName
does not have a prefix, then the namespace URI is null (this is the same
way attribute names are expanded). It is an error if the
QName
has a prefix for which there is no namespace declaration in the expression
context.
]]

Hope that helps,
Neil
[1]:
http://www.w3.org/TR/xpath#node-tests

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  neilg@ca.ibm.com




> ---------+-------------------------------->
> > Michael_Mcdonough@aig|
> > trading.com          |
> > > 
> > 08/26/2002 04:52 PM  |
> > Please respond to    |
> > xerces-j-user        |
> > > 
> ---------+-------------------------------->
  >
---------------------------------------------------------------------------------------------------------------------------------------------|


  |
> 
  |       To:       xerces-j-user@xml.apache.org
> 
  |       cc:
> 
  |       Subject:  Re: xmlvalidator does not detect violations of
uniqueness
> 
  |
> 
  |
> 
  >
---------------------------------------------------------------------------------------------------------------------------------------------|






Neil,

Thanks for this explanation.

When you say the "default namespace isn't used in xpath expressions" I'm
wondering if that is true for xpath
in general, or an omission within the Schema specification, or a failing of
Xerces, or none of the above?

Thanks,
Michael McDonough




                      neilg@ca.ibm.com

                                               To:
xerces-j-user@xml.apache.org
                      08/26/2002 04:30         cc:

                      PM                       Subject:  Re: xmlvalidator
does not detect violations of uniqueness
                      Please respond to

                      xerces-j-user







Hi Marv,

Some while back, Eddie Robertson posted a message where he diagnosed this
problem in another user's schema; perhaps a trip through the archives could
have dug out that note.

But the problem is non-obvious, so it's no doubt worth posting the cause
again:  The default namespace isn't used in xpath expressions.  So you're
<xsd:selector> is looking for a "B" element in the null namespace.  But B
is in the schema's targetNamespace, tso no element is selected and no error
detected.

The fix is to bind an explicit prefix to the schema's targetNamespace and
use that in your selector's xpath attribute.

Hope that helps,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  neilg@ca.ibm.com




> ---------+---------------------------->
> > marvin.goodgame@k|
> > odak.com         |
> > > 
> > 08/26/2002 04:20 |
> > PM               |
> > Please respond to|
> > xerces-j-user    |
> > > 
> ---------+---------------------------->
  >
---------------------------------------------------------------------------------------------------------------------------------------------|




  |
> 
  |       To:       xerces-j-user@xml.apache.org
> 
  |       cc:
> 
  |       Subject:  xmlvalidator does not detect violations of uniqueness
> 
  |
> 
  |
> 
  >
---------------------------------------------------------------------------------------------------------------------------------------------|







From: Marvin M. Goodgame

I am running an xmlvalidator application that is built on the Xerces-2.0.2
release using org.apache.xerces.parsers.SAXParser class for parsing.  The
following features are set "true" on the parser:
      http://xml.org/sax/features/validation
      http://xml.org/sax/features/namespaces
      http://apache.org/xml/features/validation/schema
      http://apache.org/xml/features/validation/schema-full-checking

This xmlvalidator fails to report the violation of uniqueness for attribute
"b":
      <A
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://www.example.com/A"
            xsi:schemaLocation="http://www.example.com/A
                                file:/home/goodgame/tmp/A.xsd">
        <B b="1"/>
        <B b="2"/>
        <B b="1"/>
      </A>

as specified in the following schema:
      <xsd:schema
              targetNamespace="http://www.example.com/A"
              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns="http://www.example.com/A">

      <xsd:complexType name="AType">
        <xsd:sequence>
          <xsd:element ref="B" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="BType">
        <xsd:attribute name="b" type="xsd:positiveInteger" use="required"/>
      </xsd:complexType>

      <xsd:element name="A" type="AType">
        <xsd:unique name="dummy">
              <xsd:selector xpath="B"/>
              <xsd:field xpath="@b"/>
        </xsd:unique>
      </xsd:element>

      <xsd:element name="B" type="BType"/>

      </xsd:schema>

Can anyone tell me what I'm doing wrong?

Thanks,
Marv



---------------------------------------------------------------------
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







---------------------------------------------------------------------
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







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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic