ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CREATE ... PARSE XML Validation

Post new topic  Reply to topic Goto page 1, 2  Next
 CREATE ... PARSE XML Validation « View previous topic :: View next topic » 
Author Message
fabyos
PostPosted: Fri May 29, 2009 2:38 pm    Post subject: CREATE ... PARSE XML Validation Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

Hi,

I'm started using WMB 6.1 4 weeks ago and I´m still new with ESQL.

I´ve a procedure that returns a CHAR result as a XML data. This result has a message set definition and I need to parse this data in order to validate the output.

So, until now, Im doing this, but no exception is thrown.

Code:

DECLARE xml CHAR;
CALL MyProcedure(..., xml);

DECLARE xmlAsBlob BLOB CAST(xml AS BLOB CCSID 1208);
CREATE LASTCHILD OF OutputRoot DOMAIN('MRM') PARSE(
      xmlAsBlob
      OPTIONS    parseOptions
      ENCODING    InputRoot.Properties.Encoding
      CCSID      1208   -- 1208=UTF-8, 819=ISO-8859-1
      SET         'PH4HRKS002001'
      TYPE       'CADPES_OUTPUT'
      FORMAT      'XML1');


and the MRM fails and have this message:

CHARACTER:ImbRecoverableException

but no exception is catched...

How do I validate a XML and if invalid throw an exception?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat May 30, 2009 1:15 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Validation happens in the parse options. You should also look at possibly wiring the error terminal to a trace terminal. Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Sat May 30, 2009 1:32 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I'm started using WMB 6.1 4

v6.1.0.3 is the latest released version. I assume that was what you meant.

Quote:
I´m still new with ESQL.
So, you should get familiar with the documentation. In particular, before you do anything which involves XML processing with message broker, you should read these topics:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac70600_.htm
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ad21074_.htm
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ad67020_.htm

If you can post to this forum then you can access all of the v6.1.0.3 documentation. So no excuses...

Quote:
the MRM fails and have this message:
CHARACTER:ImbRecoverableException

I suspect that you are trying to debug a parser problem using the message flow debugger. If so, don't. The standard advice is
- Disconnect the debugger
- Insert Trace nodes wherever you need to inspect the contents of the message tree
- Take a user trace while the message is passing througth the flow.

The debugger is good for all kinds of purposes, but not for debugging parsing errors. And user trace is very useful for all kinds of other purposes, and well worth getting familiar with.
Back to top
View user's profile Send private message
fabyos
PostPosted: Mon Jun 01, 2009 5:34 am    Post subject: Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

I forgot to follow this thread, I thought that I have no response...

@kimbert

You are right, Im using 6.1.0.3, what I mean is that I started using MB four weeks ago...

There was no error with my code, the problem was that I was debugging message flow, and this is causing that exception, when I turned off the debug I get my parse validation exception logged with trace as you said.

Thanks for response and links, some of them I´ve already read it.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 01, 2009 7:42 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
some of them I´ve already read it.
XMLNSC is the recommended way to process XML in v6.1.0.3. Why did you decide to use the not-deprecated-but-not-exactly-strategic MRM XML parser?
Back to top
View user's profile Send private message
fabyos
PostPosted: Mon Jun 01, 2009 10:01 am    Post subject: Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

kimbert wrote:
Quote:
some of them I´ve already read it.
XMLNSC is the recommended way to process XML in v6.1.0.3. Why did you decide to use the not-deprecated-but-not-exactly-strategic MRM XML parser?


There is not an exactly motive to use MRM, the primary decision was because of the test generator which bind the input node and easily create the request, but now i figure out that I can do the same thing with XMLNSC which is the proper choice to deal with XML.

I started to change my code to parse to XMLNSC but not getting success doing it.

Code:

DECLARE xmlAsBlob BLOB CAST(xml AS BLOB CCSID 1208);

      CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(
      xmlAsBlob
      OPTIONS    ValidateContentAndValue
      ENCODING    InputRoot.Properties.Encoding
      CCSID      1208   -- 1208=UTF-8, 819=ISO-8859-1
      --SET         'PH4HRKS002001'
      TYPE       'CADPES_OUTPUT'
      FORMAT      'XML1');


but Im receiving an exception with number 5028 and Insert 'PH4HRKS002001'.

I´m looking for an example but there isnt any in infocenter...
Back to top
View user's profile Send private message
fabyos
PostPosted: Mon Jun 01, 2009 10:44 am    Post subject: Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

@kimbert

The validation is now working, I just simplified the code to

Quote:
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(
xmlAsBlob);


And changed the validation to 'content and value' on my Compute Node (ESQL) and it worked.

Is it correct? How the validations is processed? He checks based on namespace and root node using the dictionary generated by all my XSD files?
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 01, 2009 11:30 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I just simplified the code to
Code:
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(
xmlAsBlob);
And changed the validation to 'content and value' on my Compute Node (ESQL) and it worked.
Is it correct?
Well, it is working as designed, but I don't blame you for asking.
The CREATE statement is just parsing the XML message. It is not doing any validation because you are not requesting validation using the Options parameter.
When the message leaves the Compute node, the OutputRoot tree is being validated by the Compute node because you have set the Validation property of the Compute node to 'Content and Value'. It just happens that OutputRoot is the target of your CREATE statement, so the net effect is that your XML gets validated.

This is not the most efficient way to do the job. Validating like this will cause OutputRoot to be serialized and reparsed. I recommend that you
- Set Validation on the Compute node to 'None'
- In the parameters of the CREATE statement, remove the TYPE and FORMAT clauses ( XMLNSC does not need them ) and ensure that the Options clause is requesting validation.
Back to top
View user's profile Send private message
fabyos
PostPosted: Mon Jun 01, 2009 12:10 pm    Post subject: Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

well.. I tried to set the options but i keep getting this exception:

Code:
(0x01000000:Name     ):ParserException = (
          (0x03000000:NameValue):File     = 'F:\build\S610_P\src\MTI\MTIforBroker\GenXmlParser4\ImbXMLNSCParser.cpp' (CHARACTER)
          (0x03000000:NameValue):Line     = 785 (INTEGER)
          (0x03000000:NameValue):Function = 'ImbXMLNSCParser::getCachedIRForMessageSet' (CHARACTER)
          (0x03000000:NameValue):Type     = 'ComIbmMQInputNode' (CHARACTER)
          (0x03000000:NameValue):Name     = '...' (CHARACTER)
          (0x03000000:NameValue):Label    = '...' (CHARACTER)
          (0x03000000:NameValue):Catalog  = 'BIPv610' (CHARACTER)
          (0x03000000:NameValue):Severity = 3 (INTEGER)
          (0x03000000:NameValue):Number   = 5028 (INTEGER)
          (0x03000000:NameValue):Text     = 'Validation is enabled but pre-processed schemas cannot be located for the specified message set ' (CHARACTER)
          (0x01000000:Name     ):Insert   = (
            (0x03000000:NameValue):Type = 5 (INTEGER)
            (0x03000000:NameValue):Text = 'PH4HRKS002001' (CHARACTER)
          )
        )


I have setted the validation to none and inserted the parse properties as i have with MRM, but no success..

I´ve tried with this:

Code:
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(
      xmlAsBlob
      OPTIONS    ValidateContentAndValue
      ENCODING    InputRoot.Properties.Encoding
      CCSID      1208   -- 1208=UTF-8, 819=ISO-8859-1
      SET         'PH4HRKS002001');


and this:

Code:
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(
      xmlAsBlob
      OPTIONS    ValidateContentAndValue
      SET         'PH4HRKS002001');


I´ve deployed and redeployed but the validation never runs...
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 01, 2009 12:17 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Aha!

In old versions of message broker ( pre v5.0, I think) you were *forced* to use the message set identifier in the SET parameter.
From vX.Y ( can't remember which ) you were able to use the message set name as an alternative.
The XMLNSC parser is thoroughly modern, and it insists that you do it the easy way. You *must* use the message set name and not the identifier.
Back to top
View user's profile Send private message
fabyos
PostPosted: Mon Jun 01, 2009 1:10 pm    Post subject: Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

kimbert wrote:
Aha!

In old versions of message broker ( pre v5.0, I think) you were *forced* to use the message set identifier in the SET parameter.
From vX.Y ( can't remember which ) you were able to use the message set name as an alternative.
The XMLNSC parser is thoroughly modern, and it insists that you do it the easy way. You *must* use the message set name and not the identifier.


Hum.. didnt work... well that exceptions doesnt happen anymore, but no validation is done too... the message with errors is created successfully with the parse...
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 01, 2009 1:36 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Hum.. didnt work... well that exceptions doesnt happen anymore
Hey, c'mon! We fixed one problem. Now we've uncovered a new one. That's standard problem solving.

Quote:
no validation is done too... the message with errors is created successfully with the parse
Details please.
Back to top
View user's profile Send private message
fabyos
PostPosted: Mon Jun 01, 2009 1:54 pm    Post subject: Reply with quote

Apprentice

Joined: 15 May 2009
Posts: 37

The message is sent with a char value instead of short (defined in XSD).

After running, the parsed tree is created with the char...

I´ve tried to create an alias to message set but it isnt founded... (response on event viewer)

Code:
CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC') PARSE(
      xmlAsBlob
      OPTIONS    ValidateContentAndValue
      ENCODING    InputRoot.Properties.Encoding
      CCSID      1208   -- 1208=UTF-8, 819=ISO-8859-1
      SET         'Person_Registry');


I´ve tried w/o ENCODING, CCSID...

Searching on info center i found this type of syntax

Code:
CREATE LASTCHILD OF OutputRoot.XMLNSC
    PARSE(X DOMAIN XMLNSC
          NAME discardComments
          OPTIONS XMLNSC.CommentsRetainNone);[quote]

what is NAME attribute for?

On this link it says to use the validation property on node..

[url]http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=/com.ibm.etools.mft.doc/ad67020_.htm[/url]

There is no log since the message is tree is created...[/quote]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jun 01, 2009 1:56 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Wouldn't you expect to create the message as last child of OutputRoot.XMLNSC instead of as last child of OutputRoot ?

The NAME attribute allows you to specify the name of your XML root tag.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Jun 01, 2009 2:27 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I´ve tried w/o ENCODING, CCSID...
Don't remove those - they're absolutely required.
Quote:
I´ve tried to create an alias to message set but it isnt founded
No need for an alias here - it's finding the message set OK.
Quote:
On this link it says to use the validation property on node
That page is explaining the basics. Most users will select the XMLNSC parser on their input node, and set the validation options there as well. You have a different requirement because your message is coming from a database as a CLOB. So you have to use CREATE...PARSE, with validation enabled via the OPTIONS parameter.

Quote:
The message is sent with a char value instead of short (defined in XSD).
Some char values are valid shorts as well...but I'll trust you
I suggest the following steps:
a) Make sure that your input XML really is invalid.
b) Take a user trace, and look carefully at the lines which happen around the setup of the XMLNSC parser. You should see validation options being read, and afterwards you should see a message about the message set being looked up.
c) try parsing this message the standard way, using an MQInput or FileInput node with Validation set to 'Content and Value'. Just to prove that it *can* work.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CREATE ... PARSE XML Validation
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.