It is normally assume that the type attribute value has a namespace prefix.
i.e ns1:complexTypeName. that is why we check for ':'
but if the complex type belongs to the default namespace the we may not have
the namespace prefix as you have mentioned.
so I change the method as follows,
java.lang.String nsPrefix = null;
                   if (fullTypeName.indexOf(":") > -1){
                       nsPrefix = fullTypeName.substring(0,
fullTypeName.indexOf(":"));
                   }

On 4/3/07, FURTADO, Murray, GBM <[EMAIL PROTECTED]> wrote:

 Hi,

I have adb generated stub classes which are subclasses of a common parent
(XPortfolioProduct). In the static method to create the parent class object
I have code as follows:


       /**
        * static method to create the object
        * Precondition:  If this object is an element, the current or next
start element starts this object and any intervening reader events are
ignorable
        *                If this object is not an element, it is a complex
type and the reader is at the event just after the outer start element
        * Postcondition: If this object is an element, the reader is
positioned at its end element
        *                If this object is a complex type, the reader is
positioned at the end element of its outer element
        */
        public static XPortfolioProduct parse(
javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
            XPortfolioProduct object = new XPortfolioProduct();
            int event;
            try {

                while (!reader.isStartElement() && !reader.isEndElement())
                    reader.next();


                if (reader.getAttributeValue("
http://www.w3.org/2001/XMLSchema-instance","type";)!=null<http://www.w3.org/2001/XMLSchema-instance%22,%22type%22%29%21=null>
){
                  java.lang.String fullTypeName = reader.getAttributeValue
("http://www.w3.org/2001/XMLSchema-instance";,
                        "type");
                  if (fullTypeName!=null){
*                    java.lang.String nsPrefix = fullTypeName.substring(0,
fullTypeName.indexOf(":"));    <--- String index out of range: -1*
                    nsPrefix = nsPrefix==null?"":nsPrefix;

                    java.lang.String type = fullTypeName.substring(
fullTypeName.indexOf(":")+1);
                    if (!"XPortfolioProduct".equals(type)){
                        //find namespace for the prefix
                        java.lang.String nsUri =
reader.getNamespaceContext().getNamespaceURI(nsPrefix);
                        return
(XPortfolioProduct)ExtensionMapper.getTypeObject(
                             nsUri,type,reader);
                      }
                  }
             }...

The fullTypeName = 'SubClassName'  and doesn't contain a colon, so a
StringIndexOutOfBoundsException is thrown.

Any idea why this is happening?


 Murray Furtado
Currency Options Sales Technology
RBS Global Banking and Markets
280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP
 ( +44 207 085 0748 | * [EMAIL PROTECTED]


***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered 
Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority

This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.
Visit our websites at:
www.rbs.comwww.rbsgc.comwww.rbsmarkets.com
***********************************************************************************




--
Amila Suriarachchi,
WSO2 Inc.

Reply via email to