- 3,715,720 Users
- 2,242,843 Discussions
- 7,845,506 Comments
Forum Stats
Discussions
Categories
- Industry Applications
- 3.2K Intelligent Advisor
- Insurance
- 1.1K On-Premises Infrastructure
- 374 Analytics Software
- 35 Application Development Software
- 1.8K Cloud Platform
- 700.5K Database Software
- 17.4K Enterprise Manager
- 7 Hardware
- 172 Infrastructure Software
- 97 Integration
- 52 Security Software
BPEL how to remove invalid (over schema validation) nodes from XML

Hello!
I want to find invalid nodes in XML over schema validation and remove it from XML.
I have
1. XSD
... <xs:element name="Client" type="tns:ClientType" maxOccurs="unbounded"/> <xs:complexType name="tns:ClientType"> <xs:sequence> <xs:element name="ClientId" type="xs:int" minOccurs="1"> <xs:element name="MiddleName" type="xs:string" minOccurs="0"/> <xs:element name="Birthday" type="xs:date" minOccurs="1"> <xs:element name="Comment" minOccurs="1"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="5"/> </xs:restriction> </xs:simpleType> </xs:element> ... </xs:sequence> </xs:complexType> ... |
---|
2. XML
<Client> <ClientId>1</ClientId> <MiddleName>MiddleName1</MiddleName> <Birthday>1988-09-29</Birthday> <Comment>Com1</Comment> ... </Client> <Client> <ClientId>2</ClientId> <MiddleName>MiddleName2</MiddleName> <Birthday>not found</Birthday> <Comment>Com2</Comment> ... </Client> <Client> <MiddleName>MiddleName</MiddleName> <Birthday>1988-03-03</Birthday> <Comment>Com</Comment> ... </Client> <Client> <ClientId>3</ClientId> <MiddleName>MiddleName3</MiddleName> <Birthday>1986-06-09</Birthday> <Comment>Comment3</Comment> ... </Client> |
---|
Expected result
<Client> <ClientId>1</ClientId> <MiddleName>MiddleName1</MiddleName> <Birthday>1988-09-29</Birthday> <Comment>Com1</Comment> ... </Client> |
---|
A Validate Activity fault does not provide information which one from "Client" nodes is not valid. A Schematron it is not XSD validation.
Could you tell me please how to remove invalid "Client" nodes from XML?
Best Answer
-
Yes that could work, looping over the node and check them one by one. But indeed, with large payloads, many occurrences it would be performance expensive.
But if you can define a proper set of possible faults, you can do the xslt first, and if that still results in an invalid xml, do a one by one validation of the elements? Then you have at least filtered the most common ones, and only do a throrough check if that fails to result in a valid xml.
However, if you would need to register which elements are ignored because of invalidity, you should perform the looped-one-by-one validation.
Regards,
Martien
Answers
-
Hi,
There's no activity that can do that. What you should do is create a transformation that only copies a client element if it applies to a set of conditions that you define in the if/choose-when tests.This is also the way to have a semantic validation of an xml.
Regards,
Martien -
Thank you, Martien.
Yes, its no bad idea, if does not change xsd often. So I try find a more universal idea. For example, in cycle split xml for few saparate xml's with one "Client" node only and then make xsd validation, create new common xml:
1) if will be validation success, then add current Client node to xml
2) if will be validation fault, then catch it and ignore it
It is need in more spending time for process when a lot nodes, so it is not a best design.
-
Yes that could work, looping over the node and check them one by one. But indeed, with large payloads, many occurrences it would be performance expensive.
But if you can define a proper set of possible faults, you can do the xslt first, and if that still results in an invalid xml, do a one by one validation of the elements? Then you have at least filtered the most common ones, and only do a throrough check if that fails to result in a valid xml.
However, if you would need to register which elements are ignored because of invalidity, you should perform the looped-one-by-one validation.
Regards,
Martien