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 » Generic Schema to be used in ESQL - Message Broker

Post new topic  Reply to topic
 Generic Schema to be used in ESQL - Message Broker « View previous topic :: View next topic » 
Author Message
constantlearner
PostPosted: Sat Jan 09, 2010 10:11 am    Post subject: Generic Schema to be used in ESQL - Message Broker Reply with quote

Newbie

Joined: 08 Jan 2010
Posts: 8

Hi,

I have a requirement in which i need to create a schema which looks very generic, for e.g. my xml looks like
Code:

<Sales>
<Product>test</Product>
<Amount>245.80</Amount>
<ExtraCharges>
<Tax>5.6</Tax>
<Authority>ABC</Authority>
<Area>878</Area>
</ExtraCharges>
</Sales>


Now in the above xml, i know that every sales will have product, amount and extracharges. But within extracharges, every application can write some new tag, i.e. there is no defined tag within ExtraCharges. In the above example, we have tax, authority and area but my application can get something like <firstname>Antony</firstname> also in ExtraCharges.

ExtraCharges has thus to be defined as a tag in schema that can hold any other kind of tag. How should i define the schema in this case?

Thanks,
Antony[/code]
Back to top
View user's profile Send private message
smdavies99
PostPosted: Sat Jan 09, 2010 10:57 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

If you know ALL the different tags that you will ever get then you can define them in a message model with the numoccurs=0.
Otherwise, you are going to have to rely on the self describing features of XML. This makes things somewhat more difficult and will most likely involve a lot more ESQL that you'd otherwise need.

Try a search on this forum for 'self describing xml' That may help.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
kimbert
PostPosted: Sat Jan 09, 2010 1:29 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

First, if you are not already doing so, I recommend strongly that you use XMLNSC for this, and not MRM XML.

It may be worth your while to bookmark the XML Schema primer here:
http://www.w3.org/TR/xmlschema-0/
...and perhaps also the W3Schools schema tutorial here:
http://www.w3schools.com/Schema/default.asp

Quote:
ExtraCharges has thus to be defined as a tag in schema that can hold any other kind of tag.
You need to add an 'any' element as the only child of ExtraCharges.
http://www.w3.org/TR/xmlschema-0/#any
In the Message Broker Toolkit, you add an 'any' element as follows:
- Highlight ExtraCharges in the Outline view ( bottom left pane )
- Right-click and select 'Add wildcard element'.

You should then set the processContents and namespaces properties to get the required level of strictness ( you may not really want *any* tag to be included. Perhaps all of the allowed tags must come from a particular namespace? ).
Back to top
View user's profile Send private message
constantlearner
PostPosted: Sun Jan 17, 2010 6:32 pm    Post subject: Reply with quote

Newbie

Joined: 08 Jan 2010
Posts: 8

Kimbert, thanks for the links, it was really helpful.
I defined an element within my schema as below
Code:

<xsd:element name="Payload" type="PayloadType"/>


The PayloadType I defined as below (so that it can take any kind of tags within it)

Code:

<xsd:complexType name="PayloadType">
      <xsd:sequence>
         <xsd:any/>
      </xsd:sequence>
      <xsd:anyAttribute/>
   </xsd:complexType>


Now when I try defining my XML as below
Code:

<Main>
   <Payload>
      <test>a</test>
   </Payload>
</Main>


I'm getting the below error in XML Spy
Code:

cvc-wildcard.2: While validating against complex type 'PayloadType', element <test> matched wildcard {##any} but no element declaration was found.


Two questions
1) Even though I defined the "any" tag and "any" attribute, I'm getting error while validating my input file against the schema
2) The Payload tag should be able to accept CDATA, XML and string types of messages. How should I define my Payload Element in Schema?

Thanks,
A--
Back to top
View user's profile Send private message
constantlearner
PostPosted: Sun Jan 17, 2010 6:40 pm    Post subject: Reply with quote

Newbie

Joined: 08 Jan 2010
Posts: 8

Kimbert wrote:
Quote:

- Right-click and select 'Add wildcard element'.


I have broker toolkit version 6.1.0.3 and I dont see this option in it.

Kimbert wrote:
Quote:

You should then set the processContents and namespaces properties to get the required level of strictness ( you may not really want *any* tag to be included. Perhaps all of the allowed tags must come from a particular namespace? ).


The requirement says the tag can be anything, it need not come from a particular namespace.
Back to top
View user's profile Send private message
goffinf
PostPosted: Tue Jan 19, 2010 3:54 pm    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Since your xsd:any element declaration does not explicitly specify a value for the processContents attribute, it will default to 'strict'. In this mode the processor MUST validate elements that appear in the place of the wildcard.

I would suggest you set a processContents value of 'lax'.

Similarly if you want to allow elements to appear in place of the wildcard from any namespace you would specify a namespace attribute value of ##any.

Fraser.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Generic Schema to be used in ESQL - Message Broker
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.