Guest
Welcome login
Share/Save
Share/Save
TIBCOmmunity > Products > ActiveMatrix SOA > BusinessWorks > Conversations
Home   Members Communities
Conversations () Resources () Blogs ()

BusinessWorks

Up to Conversations in BusinessWorks

This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)

Hi All,

 

i am having an issue with parser while my xml data contains invalid characters ( like '&' ) ....

 

i have this requirement that customer data may contain these sort of characters in any place/location of xml ..... we need to process them.

tried using CDATA but ineffective... will appreciate help from gurus on this site...

 

 

 

Thanks,

 

Shahid

Click to view Tom Howard's profile Dabbler 24 posts since
Oct 22, 2008

CDATA should work. Do you have an example?

Click to view Tom Howard's profile Dabbler 24 posts since
Oct 22, 2008

http://www.tibcommunity.com/message/36129#36129 has a working example of adding CDATA to cope with '&'

Click to view Yeshodhan Kulkarni's profile Hotshot 152 posts since
May 21, 2009

I had faced a similar issue earlier and the solution we applied was a replaceAll custom java function.

 

Before parsing, we replaced all occurrences of & with & named entity and then parsed the string.

 

Regards ~ Yeshodhan

Click to view SID's profile Dabbler 28 posts since
Oct 24, 2008

If you add CDATA block it should get parsed.

 

Please find attached a sample POC on how to add the CDATA in BW and get it parsed successfully.

 

If you dont want to use CDATA block just want to pass individual strings you can just use a render-xml activity in between and then pass the render-xm string to the parse-xml activity.

Attachments:
Click to view Tom Howard's profile Dabbler 24 posts since
Oct 22, 2008

Hi Shahid,

 

Are you being asked to work around a defect in an existing system, or is it a theoretical requirement (i.e., the system is yet to be build, but the customer wants your stuff to be "robust")?

 

If it is the latter, then you should remind the powers that be that any interaction between two systems should have a interface contract that both teams have negotiated and agree to. Point out to them that without interface contracts you will have defects caused by misunderstandings between the teams, that no level of safe guards (like the ability to handle arbitrary '&' characters) will prevent. Once everyone agree's that an interface contract is required, then negotiate with the other team that they must provide you with valid XML. Anything less and you may as well bend over.

Click to view Tom Howard's profile Dabbler 24 posts since
Oct 22, 2008

Hi Yeshodhan,

 

You've got to be careful with blanket '&' replacements as well. I remember having to deal with a system where sometimes you would get named entities, like '<' and other times you would get '&'.

Click to view SID's profile Dabbler 28 posts since
Oct 24, 2008

yes Tom i do agree with you that the third party should send a valid xml and search and replace does have its limitation and also it effects the design

Click to view SenHu's profile Dabbler 1 posts since
Feb 22, 2010

You can use biterscripting for parsing XML with special characters.

 

A sample XML:

 

<expression>

<type>arithmetic</type>

<syntax>(X+Y)</syntax>

</expression>

<expression>

<type>boolean</type>

<syntax>((X+Y)<(Z+3))&&(3>A)</syntax>

</expression>

 

 

Sample biterscripting code to get the <syntax>es from the above sample XML:

 

var str xml, node

cat "http://www.abc_xyz.com/path/to/file.xml" > $xml

while ( { sen -r -c "<syntax&\>&</syntax&\>" $xml } > 0 )

do

# Get <syntax...>...</syntax...>

stex -r -c "^<syntax&\>&</syntax&\>^" $xml > $node

# Strip off <syntax...>

stex -r -c "^<syntax&\>^]" $node > null

# Strip off </syntax...>

stex -r -c "[^</syntax&\>^" $node > null

# Display $node

echo $node

done

 

 

Will display

 

(X+Y)
((X+Y)<(Z+3))&&(3>A)



More Like This

  • Retrieving data ...