Your schema sets up the namespace, thank you.

The problem remains though!!

Here is the code, it is the onMessage method of a message driven bean:

public void onMessage( Message msg ) {
    LOGGER.debug( "Got a monitoring message!" );

    ObjectMessage om;
    LoggingEvent event;
    String xml;
    TestDocument testDocument;
    Test test;
    if( msg instanceof ObjectMessage ) {
      om = (ObjectMessage)msg;
      try {
        // Get the logging event from Log4J
        event = (LoggingEvent)om.getObject();

        // Check the data type
        LOGGER.debug("The data is an instance of " +
event.getMessage().getClass());
        LOGGER.debug("At level " + event.getLevel().toString());
        // Log4J specification says that the message will be returned as a
string
        if(event.getMessage() instanceof java.lang.String) {
          LOGGER.debug("The string is " + event.getMessage().toString());
          // Unmarshall the xml
          testDocument = TestDocument.Factory.parse(
event.getMessage().toString() );
          LOGGER.debug( "Done the unmarshalling");
          test = testDocument.getTest();
          LOGGER.debug("The id is " + test.getTest1());
        }
        else {
          LOGGER.info(event.getMessage().toString());
        }
      }
      catch( javax.jms.JMSException ex ) {
        LOGGER.error( "JMS exception when getting the logging event : ", ex
);
      }
      catch( Exception x ) {
        LOGGER.error( "Error : ", x );
      }

    }
    else {
      try {
        LOGGER.warn( "Warning - the data type is " + msg.getJMSType() + ",
the expected type was ObjectMessage" );
      }
      catch( javax.jms.JMSException ex ) {
        LOGGER.error( "JMS exception when getting the JMS data type: ", ex
);
      }
    }

    LOGGER.debug( "Processed monitoring data!" );
  }

The output from the debug (log4j) log is:
2005-07-18 13:07:35,648 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:66)
 - Got a monitoring message!
2005-07-18 13:07:35,667 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:82)
 - The data is an instance of class java.lang.String
2005-07-18 13:07:35,668 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:83)
 - At level INFO
2005-07-18 13:07:35,669 [ExecuteThread: '13' for queue:
'weblogic.kernel.Default'] DEBUG (MonitorSubscriberBean.java:86)
 - The string is <test test2="test 2" test1="test 1"
xmlns="http://cpp.co.uk/test"/>

So we can see that the xml coming through is ok, and now has the namespace
specified, but the code does not get any further - the debug after the parse
never appears.

Any ideas? Many thanks. :-)

-----Original Message-----
From: Arek Stryjski [mailto:[EMAIL PROTECTED] 
Sent: 18 July 2005 12:48
To: [email protected]
Subject: Re: Parsing xml

On 18/07/05, Caroline Wood <[EMAIL PROTECTED]> wrote:
> 
> Hi Arek,
> 
> Thanks for your reply :-)
> 
> I've not set up a namespace, so the reference to the class is
> noNamespace.TestDocument. How do you set up a namespace?

I believe your Schema should be:

<schema xmlns="http://www.w3.org/2001/XMLSchema";
        targetNamespace="http://cpp.co.uk/test";
        xmlns:xs="http://www.w3.org/2001/XMLSchema";
        xmlns:ccp="http://cpp.co.uk/test";
        elementFormDefault="qualified"
        attributeFormDefault="unqualified">

<element name="test" type="ccp:Test"/>

<complexType name="Test">
    <sequence/>
    <attribute name="test1" type="xs:string"/>
    <attribute name="tes2" type="xs:string"/>
</complexType>

</schema>

or something similar. 
You should be able to parse XML similar to one I send before with
uk.co.ccp.test.TestDocument

Now in new XMLBeans (v.2) there is also some other way to set package,
but unfortunately I don't remember it. Anyway I'm using it as
described before and has no problem with parsing.

Best regards
Arek

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


This is an email from the CPP Group Plc, Holgate Park, York, YO26 4GA; 
telephone 01904 544500.
This message may contain information that is confidential. If you are not the 
intended recipient,
you may not peruse, use, disseminate, distribute or copy this message. If you 
have received this
message in error, please notify the sender immediately by email, facsimile or 
telephone and either
return or destroy the original message.
The CPP Group Plc accepts no responsibility for any changes made to this 
message after it has been
sent by the original author.  This email has been scanned for all viruses by 
the MessageLabs Email Security System.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to