How to write XSD to validate escaped xml data pattern

chrisd

New Member
I got a specific xml data below\[code\]<l7:ApiPlans xmlns:l7="http://ns.xcompany.com/2012/04/api-management"> <l7:ApiPlan><l7:PlanPolicy><wsp:Policy xmlns:L7p="http://www.xcompany.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"><wsp:All wsp:Usage="Required"> <wsp:All wsp:Usage="Required"> ...... some other welformed xml</wsp:All> </wsp:All></wsp:Policy> </l7:PlanPolicy> </l7:ApiPlan></l7:ApiPlans>\[/code\]That I need to write an XSD (if possible) to validate that PlanPolicy starts with \[code\]<wsp:Policy xmlns:L7p="http://www.xcompany.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"><wsp:All wsp:Usage="Required"> <wsp:All wsp:Usage="Required">\[/code\]and ends with \[code\] </wsp:All> </wsp:All> </wsp:Policy>\[/code\]So far I have this,\[code\]<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://ns.xcompany.com/2012/04/api-management" xmlns:l7="http://ns.xcompany.com/2012/04/api-management"><xs:element name="ApiPlans"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="l7:ApiPlan"/> </xs:sequence> </xs:complexType></xs:element><xs:element name="ApiPlan"> <xs:complexType> <xs:sequence> <xs:element ref="l7:PlanPolicy"/> </xs:sequence> </xs:complexType></xs:element><xs:element name="PlanPolicy" type="policyDataType"/><simpleType name="policyDataType"> <restriction base="xs:string"> <minLength value="http://stackoverflow.com/questions/10789076/1"></minLength> <pattern value="http://stackoverflow.com/questions/10789076/(<).*(>).*(<).*(>)"></pattern> </restriction></simpleType></xs:schema>\[/code\]Is that possible? And as a side question, How do you define in pattern: new lines(CR/LF), tab and quotes.Thanks in advance
 
Back
Top