Invalid data characters in xml

Is there any flowservice which takes the xml as input and converts “all the xml not allowed charecters”
to entity references
convert → &, > , < , ', " to their corresponding entity references → &,…

No builtin,

But originally your xml should come with & < etc…wellformed ,otherwise NodeToDocumetnt parsing will fail…It should be taken care of the source app who is sending the file.

HTH,
RMG

Try using pub.string:HTMLEncode (in the package WmPublic). It converts the following four chars - if you want chars besides these, you can try writing a service of your own.

HTMLEcode replaces:

&, <, > and "

HTH

Using pub.xml:documentToXMLString you can specify following input parameter to true

encode
String Optional. Flag indicating whether to HTML-encode the data. Set thisparameter to true if your XML data contains special characters, including the
following: < > & " ’

Using pub.xml:xmlStringToXMLNode you can specify following input parameter to the desired character-set (UTF-8 for xml) :

encoding

String Optional. Character encoding in which text is represented. Specify UTF-8 for XML files and ISO-8859-1 for HTML files. To have the parser attempt to detect the type of encoding, specify autoDetect (the default, if encoding is not specified).

Regards,
Djibril.

Thank you for the replies. pub.string:HTMLEncode works but I don’t know which input elements need to be encoded. I want the whole xml to be encoded.

I am getting the xml in the encoded format
for eg input xml:

<?xml version="1.0" encoding="UTF-8"?> 1 test & desc

I have
xmlNodeToDocument → this is converting “test & desc” to “test & desc”
and
when I use “documentToXmlString” and eventhough I set the “encode” to true, nothing is happening. I am seeing the xml as “test & desc”.

When this unencoded (“test & desc”) is validated, validation is failing.

This is correct behavior. The decoding is expected and desired.

This is not expected. When encode is set to true, all fields in the document will be encoded. If this is not happening, you should open a service request with wM tech support.

Sudheshna,

xmlNodeToDocument → this is converting “test & desc” to “test & desc” --This is as expected

When you set encode=true in “documentToXmlString” it should give with test & desc but should not “test & Desc” which is invalid encoded and not wellformed XML.

HTH,
RMG

I have same kind of issue. below is the Input receiving from a merchant.

<?xml version="1.0" encoding="utf-8" ?>

<Advice_of_Order sender_id=“A24” receiver_id=“006026793” xg_batch_id=“B254823” file_creation_date=“2006-10-03” test_indicator=“P” transtype=“AOO”><Order_Header merchant_id=“A24” order_number=“254823”
order_date=“2006-10-03” transaction_type=“N” customer_number=“” ship_to_name=“Kimberly Anne Coles” ship_to_address1=“27 Orchard St.” ship_to_address2=“” ship_to_city=“Cortland” ship_to_state=“NY”
ship_to_zipcode=“13045” ship_to_country=“USA” shipping_handling=“0.00” sales_tax=“0.00” line_item_total_amt=“0.00” order_total_amt=“0.00” merchant_msg_line1=“Hey baby, I don’t know if this was what
you want. My phone broke and I had it in” merchant_msg_line2=" a text message. I hope you like it and I can’t wait to see you. I love you." merchant_msg_line3=“Syracuse University Bookstore
303 University Place " merchant_msg_line4=“Syracuse NY13244(315)443-1668 " carrier=“GUPS” delivery_method=“GR” order_discount=“0.00” total_nbr_lines=“1”>
<Order_Detail line_number=“1” sku_number=“11605” sku_description=“Tote” unit_measure=“EA” order_qty=“1” list_price=“0.00” extended_price=“0.00” line_comment=”” /></Order_Header></Advice_of_Order>

Steps following:
1:pub.string:bytesToString
2:pub.xml.xmlStringToXMLNode
Encoding: UTF-8
expand DTD: true
is XML: autodetect
3:pub.schema:validate
confirms To: schema path
max errors: -1
at this step we are getting Validation error. It is due to speacial character- “Hey baby, I don’t know …”.
Please lets us know the steps to be followed…

Thanks&Regards
Kartheek

Kartheek,

Check your schema definition for that particular field. Maybe it is restricting the use of any special characters.

YLO,
Thanks for your response. It don’t have restrictions. It has min-0 and max-80. Initially i was getting maxLength error on that field but after removing few chars also validation is getting failed.

Thanks
Kartheek

Did you manually edit the data with " (for ") and tried to validate?? try if this works??

HTH,
RMG

The fix is for the merchant to send valid XML, with appropriate character entities substituted for characters per the standards. There is nothing you can (reasonably) do to fix bad XML.