You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Amila Suriarachchi <am...@gmail.com> on 2007/10/05 07:06:23 UTC
Re: Problem with ConverterUtil convertTo* methods and empty XML tag
Can you send a sample schema and sample xml you get as well?
I guess you talk something like this.
<xs:element name="test" type="xs:int"/>
and you get an xml for this like this
<test></test>
My question is, is this a valid xml for this? if the type is int there must
be an int inside it.
on the other hand you can have
<xs:element nillable="true" minOccurs="0" name="test" type="xs:int"/>
to represent that is null. but above is an invalid xml.
Amila.
On 9/25/07, Jozef Krssak <jo...@gmail.com> wrote:
>
> Hi
>
> During tests of Axis2 1.3 parser speed performance for our existing
> project we have found big problem in
> org.apache.axis2.databinding.utils.ConverterUtil and its convertTo*
> methods when processed XML has some empty tags. Convert methods have no
> code to test given parameter to 'null' value or value equals to "".
>
> To be able to parse any XML we had to add the following simple code into
> these methods:
> if (s == null || "".equals(s)) {
> return null;
> }
>
> We think it will be worth to fix it and add this simple code.
> Thanks
>
> --
> Jozef Krssak
>
>
--
Amila Suriarachchi,
WSO2 Inc.
Re: Problem with ConverterUtil convertTo* methods and empty XML tag
Posted by WJ Krpelan <kr...@yahoo.com>.
Hi
the problem with non-perfect XSD is that its no longer
XSD proper and the whole idea of a world-wide agreed
interface standard collapses.
An official XSD-tool must not support inofficial
XSD-modifications.
Your customer cant Schema-validate his non-perfect XML
with standard tools either
Cheers
--- Jozef Krssak <jo...@gmail.com> wrote:
> Hi
>
> ok, my customer hasn't absolutely perfect XSD and
> sends to me empty elements
> even if their type is int.
>
> I think primary problem is that utility class
> ConverterUtil and its methods
> do not check input parameters for values null or
> empty string to avoid
> useless exceptions like:
>
> java.lang.RuntimeException: In valid string to parse
> in convertToDate(String) method
>
> or
> java.lang.NumberFormatException
> in convertToDecimal(String) method
>
>
> Is there any reason why robustness of common utility
> class ConverterUtil
> cannot be improved? In many cases if input parameter
> is null of empty string
> the valid return value is null, I think.
>
> --
> Jozef Krssak
>
>
> On 10/8/07, Amila Suriarachchi
> <am...@gmail.com> wrote:
> >
> > you have to declare your element as nillable=true
> if you want to have
> > xs:nil=true
> >
> > <xsd:element name="EndDate" type="tns:WSTypeDate"
> nillable="true"/>
> >
> > Amila.
> >
> > On 10/8/07, Jozef Krssak <jo...@gmail.com>
> wrote:
> > >
> > > Hi
> > >
> > > Element definition in schema:
> > >
> > > <xsd:element name="EndDate"
> type="wsct:WSTypeDate" minOccurs="1"/>
> > >
> > > Type "wsct:WSTypeDate" is in other schema as:
> > >
> > > <xsd:simpleType name="WSTypeDate">
> > > <xsd:restriction base="xsd:date">
> > > <xsd:pattern
> value='[0-9]{4}-[0-9]{2}-[0-9]{2}'/>
> > > </xsd:restriction>
> > > </xsd:simpleType>
> > >
> > >
> > > Element in XML:
> > >
> > > <EndDate xsi:nil="true"/>
> > >
> > >
> > > Another one example:
> > > <xsd:element name="SMS_Provider"
> type="wsct:WSTypeChar3" minOccurs="1"/>
> > >
> > > <xsd:simpleType
> name="WSTypeChar3"><xsd:restriction
> > > base="xsd:string"><xsd:maxLength
> > > value="3"/></xsd:restriction></xsd:simpleType>
> > >
> > > <SMS_Provider xsi:nil="true"/>
> > >
> > >
> > >
> > > Thanks and Regards
> > > --
> > > Jozef Krssak
> > >
> > >
> > > On 10/5/07, Amila Suriarachchi <
> amilasuriarachchi@gmail.com> wrote:
> > > >
> > > > Can you send a sample schema and sample xml
> you get as well?
> > > >
> > > > I guess you talk something like this.
> > > >
> > > > <xs:element name="test" type="xs:int"/>
> > > >
> > > > and you get an xml for this like this
> > > >
> > > > <test></test>
> > > >
> > > > My question is, is this a valid xml for this?
> if the type is int there
> > > > must be an int inside it.
> > > >
> > > > on the other hand you can have
> > > > <xs:element nillable="true" minOccurs="0"
> name="test" type="xs:int"/>
> > > >
> > > >
> > > > to represent that is null. but above is an
> invalid xml.
> > > >
> > > > Amila.
> > > >
> > >
> > >
> >
> >
> > --
> > Amila Suriarachchi,
> > WSO2 Inc.
>
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: Problem with ConverterUtil convertTo* methods and empty XML tag
Posted by Jozef Krssak <jo...@gmail.com>.
Hi
ok, my customer hasn't absolutely perfect XSD and sends to me empty elements
even if their type is int.
I think primary problem is that utility class ConverterUtil and its methods
do not check input parameters for values null or empty string to avoid
useless exceptions like:
java.lang.RuntimeException: In valid string to parse
in convertToDate(String) method
or
java.lang.NumberFormatException
in convertToDecimal(String) method
Is there any reason why robustness of common utility class ConverterUtil
cannot be improved? In many cases if input parameter is null of empty string
the valid return value is null, I think.
--
Jozef Krssak
On 10/8/07, Amila Suriarachchi <am...@gmail.com> wrote:
>
> you have to declare your element as nillable=true if you want to have
> xs:nil=true
>
> <xsd:element name="EndDate" type="tns:WSTypeDate" nillable="true"/>
>
> Amila.
>
> On 10/8/07, Jozef Krssak <jo...@gmail.com> wrote:
> >
> > Hi
> >
> > Element definition in schema:
> >
> > <xsd:element name="EndDate" type="wsct:WSTypeDate" minOccurs="1"/>
> >
> > Type "wsct:WSTypeDate" is in other schema as:
> >
> > <xsd:simpleType name="WSTypeDate">
> > <xsd:restriction base="xsd:date">
> > <xsd:pattern value='[0-9]{4}-[0-9]{2}-[0-9]{2}'/>
> > </xsd:restriction>
> > </xsd:simpleType>
> >
> >
> > Element in XML:
> >
> > <EndDate xsi:nil="true"/>
> >
> >
> > Another one example:
> > <xsd:element name="SMS_Provider" type="wsct:WSTypeChar3" minOccurs="1"/>
> >
> > <xsd:simpleType name="WSTypeChar3"><xsd:restriction
> > base="xsd:string"><xsd:maxLength
> > value="3"/></xsd:restriction></xsd:simpleType>
> >
> > <SMS_Provider xsi:nil="true"/>
> >
> >
> >
> > Thanks and Regards
> > --
> > Jozef Krssak
> >
> >
> > On 10/5/07, Amila Suriarachchi < amilasuriarachchi@gmail.com> wrote:
> > >
> > > Can you send a sample schema and sample xml you get as well?
> > >
> > > I guess you talk something like this.
> > >
> > > <xs:element name="test" type="xs:int"/>
> > >
> > > and you get an xml for this like this
> > >
> > > <test></test>
> > >
> > > My question is, is this a valid xml for this? if the type is int there
> > > must be an int inside it.
> > >
> > > on the other hand you can have
> > > <xs:element nillable="true" minOccurs="0" name="test" type="xs:int"/>
> > >
> > >
> > > to represent that is null. but above is an invalid xml.
> > >
> > > Amila.
> > >
> >
> >
>
>
> --
> Amila Suriarachchi,
> WSO2 Inc.
Re: Problem with ConverterUtil convertTo* methods and empty XML tag
Posted by Jozef Krssak <jo...@gmail.com>.
Hi
Element definition in schema:
<xsd:element name="EndDate" type="wsct:WSTypeDate" minOccurs="1"/>
Type "wsct:WSTypeDate" is in other schema as:
<xsd:simpleType name="WSTypeDate">
<xsd:restriction base="xsd:date">
<xsd:pattern value='[0-9]{4}-[0-9]{2}-[0-9]{2}'/>
</xsd:restriction>
</xsd:simpleType>
Element in XML:
<EndDate xsi:nil="true"/>
Another one example:
<xsd:element name="SMS_Provider" type="wsct:WSTypeChar3" minOccurs="1"/>
<xsd:simpleType name="WSTypeChar3"><xsd:restriction
base="xsd:string"><xsd:maxLength
value="3"/></xsd:restriction></xsd:simpleType>
<SMS_Provider xsi:nil="true"/>
Thanks and Regards
--
Jozef Krssak
On 10/5/07, Amila Suriarachchi <am...@gmail.com> wrote:
>
> Can you send a sample schema and sample xml you get as well?
>
> I guess you talk something like this.
>
> <xs:element name="test" type="xs:int"/>
>
> and you get an xml for this like this
>
> <test></test>
>
> My question is, is this a valid xml for this? if the type is int there
> must be an int inside it.
>
> on the other hand you can have
> <xs:element nillable="true" minOccurs="0" name="test" type="xs:int"/>
>
> to represent that is null. but above is an invalid xml.
>
> Amila.
>