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 PHDB _ <ph...@hotmail.com> on 2004/06/02 15:31:56 UTC

Weird error detection : Xerces bug ?

Hi all,

I've got a strong behavior of Xerces when validating this file, where 
StartTime does not respect the pattern HHMM
------
<Booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="Booking.xsd">
	<StartTime>20154</StartTime>
	<StopTime>2050</StopTime>
</Booking>
-------

where Booking.xsd is
----------------
Booking.xsd
----------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="Booking" type="Booking_Type"/>
	<xs:complexType name="Booking_Type">
		<xs:sequence>
			<xs:sequence minOccurs="0">
				<xs:element name="Location1" type="CityCode"/>
				<xs:element name="Location2" type="CityCode" minOccurs="0"/>
			</xs:sequence>
			<xs:sequence minOccurs="0">
				<xs:element name="StartDate" type="xs:date"/>
				<xs:element name="StopDate" type="xs:date"/>
			</xs:sequence>
			<xs:sequence minOccurs="0">
				<xs:element name="StartTime" type="TimeHHMM"/>
				<xs:element name="StopTime" type="TimeHHMM" minOccurs="0"/>
			</xs:sequence>
		</xs:sequence>
	</xs:complexType>
	<xs:simpleType name="CityCode">
		<xs:restriction base="xs:string">
			<xs:pattern value="[A-Z][A-Z0-9]{2,4}"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="TimeHHMM">
		<xs:restriction base="xs:string">
			<xs:pattern 
value="(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>
-------------------------------------

Instead of giving me
Value does not match facet 
pattern=="(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)" 
in element 'StartTime'
I have
Mandatory element 'Location1' expected in place of 'StartTime'
But there is no relationship between Location1 and StartTime elements !!


And the weirdest is that with this other file below, where I just added some 
fields before StartTime, the error is well displayed :
Value does not match facet 
pattern=="(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)" 
in element 'StartTime'

------------
<Booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="Booking.xsd">
	<StartDate>2001-11-12</StartDate>
	<StopDate>2001-01-03</StopDate>
	<StartTime>20154</StartTime>
	<StopTime>2050</StopTime>
</Booking>
-------------


Any hint ???

Thks in advance

_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous !  
http://search.msn.fr/


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


Re: Parsing processing instructions

Posted by Robert van Loenhout <r....@greenvalley.nl>.
Joseph Kesselman wrote:
> > It's not without reason that the XML specification calls them
> > "pseudo-attributes". The content of a PI can be anything,
>
> Specific citation: http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi
>
> A PI's contents are its target name, and a block of arbitrary characters,
> separated by whitespace.  The interpretation of that character data is up
> to whoever defined the PI. It may look like attributes... or it may look
> like anything else which that PI considers meaningful. The only rule is
> that the value can't contain the ?> sequence which ends the PI.

Okay, that makes sense why Xerces does not parse the PI's.
Although I don't think it was the right choice of w3c to allow any content
in the PI.

So with some regular expression I managed to do a name/value parsing that is
enough for now.

Thanks for the information.


                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

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


Re: Parsing processing instructions

Posted by Joseph Kesselman <ke...@us.ibm.com>.



>It's not without reason that the XML specification calls them
>"pseudo-attributes". The content of a PI can be anything,

Specific citation: http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi

A PI's contents are its target name, and a block of arbitrary characters,
separated by whitespace.  The interpretation of that character data is up
to whoever defined the PI. It may look like attributes... or it may look
like anything else which that PI considers meaningful. The only rule is
that the value can't contain the ?> sequence which ends the PI.

Yeah, it might be nice if XML APIs provided a convenience function to parse
pseudo-attributes out of an arbitrary string, since that syntax does get
reused in PIs and elsewhere. At the moment they don't.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


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


Re: Parsing processing instructions

Posted by Sebastian Redl <wa...@gmx.net>.
Robert van Loenhout wrote:

>Hi,
>
>I could parse it manually, but I find it strange that I would have to do
>this since I am already using a parser and the attributes of a processing
>instruction seems the same to me as any element.
>
>  
>
It's not without reason that the XML specification calls them 
"pseudo-attributes". The content of a PI can be anything, and if that 
anything takes the form of attributes then this is conincidence. It's up 
to the user of the PI to parse its contents.

Sebastian Redl

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


Parsing processing instructions

Posted by Robert van Loenhout <r....@greenvalley.nl>.
Hi,

Is there some easy way with Xerces to parse the attributes of processing
instructions in XML?
I tried using the getAttributes method of the ProcessingInstruction, but
this return null just
like it says in the documentation:
"A NamedNodeMap containing the attributes of this node (if it is an Element)
or null otherwise."

I could parse it manually, but I find it strange that I would have to do
this since I am already using a parser and the attributes of a processing
instruction seems the same to me as any element.




                                                                              
                                                                              
                                                                               
                                                                            

                
                                                                 

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


Re: Weird error detection : Xerces bug ?

Posted by Neil Delima <nd...@ca.ibm.com>.



Works for me with Xerces-2J_2.6.2 on Sun's 1.3.1 JDK.  Your expected error
message does not appear to originate from Xerces-2J_2.6.2.  What version
of Xerces and JDK are you using?

Xerces Output for:  java sax.Counter -v -s -f Booking.xml
[Error] Booking.xml:3:32: cvc-pattern-valid: Value '20154' is not
facet-valid with
respect to pattern
'(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)'
for type 'TimeHHMM'.
[Error] Booking.xml:3:32: cvc-type.3.1.3: The value '20154' of element
'StartTime'
is not valid.
Booking.xml: 821 ms (3 elems, 1 attrs, 0 spaces, 18 chars)



"PHDB _" <ph...@hotmail.com> wrote on 06/02/2004 09:31:56 AM:

> Hi all,
>
> I've got a strong behavior of Xerces when validating this file, where
> StartTime does not respect the pattern HHMM
> ------
> <Booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="Booking.xsd">
>    <StartTime>20154</StartTime>
>    <StopTime>2050</StopTime>
> </Booking>
> -------
>
> where Booking.xsd is
> ----------------
> Booking.xsd
> ----------------
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
>    <xs:element name="Booking" type="Booking_Type"/>
>    <xs:complexType name="Booking_Type">
>       <xs:sequence>
>          <xs:sequence minOccurs="0">
>             <xs:element name="Location1" type="CityCode"/>
>             <xs:element name="Location2" type="CityCode" minOccurs="0"/>
>          </xs:sequence>
>          <xs:sequence minOccurs="0">
>             <xs:element name="StartDate" type="xs:date"/>
>             <xs:element name="StopDate" type="xs:date"/>
>          </xs:sequence>
>          <xs:sequence minOccurs="0">
>             <xs:element name="StartTime" type="TimeHHMM"/>
>             <xs:element name="StopTime" type="TimeHHMM" minOccurs="0"/>
>          </xs:sequence>
>       </xs:sequence>
>    </xs:complexType>
>    <xs:simpleType name="CityCode">
>       <xs:restriction base="xs:string">
>          <xs:pattern value="[A-Z][A-Z0-9]{2,4}"/>
>       </xs:restriction>
>    </xs:simpleType>
>    <xs:simpleType name="TimeHHMM">
>       <xs:restriction base="xs:string">
>          <xs:pattern
>
value="(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)"/>
>       </xs:restriction>
>    </xs:simpleType>
> </xs:schema>
> -------------------------------------
>
> Instead of giving me
> Value does not match facet
>
pattern=="(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)"

> in element 'StartTime'
> I have
> Mandatory element 'Location1' expected in place of 'StartTime'
> But there is no relationship between Location1 and StartTime elements !!
>
>
> And the weirdest is that with this other file below, where I just added
some
> fields before StartTime, the error is well displayed :
> Value does not match facet
>
pattern=="(00(0[1-9]|[1-5][0-9]))|((0[1-9]|1[0-9]|2[0-3])[0-5][0-9])|(2400)"

> in element 'StartTime'
>
> ------------
> <Booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="Booking.xsd">
>    <StartDate>2001-11-12</StartDate>
>    <StopDate>2001-01-03</StopDate>
>    <StartTime>20154</StartTime>
>    <StopTime>2050</StopTime>
> </Booking>
> -------------
>
>
> Any hint ???
>
> Thks in advance
>
> _________________________________________________________________
> MSN Search, le moteur de recherche qui pense comme vous !
> http://search.msn.fr/
>
>
> ---------------------------------------------------------------------
> 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