It seems that I am facing some problem while validating this XML
This is XML ,which I have created.
<?xml version="1.0" encoding="UTF-8"?>
<emp_comp xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-04-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
</emp>
</emp_comp>
Corresponding schema is
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="emp_comp">
<xs:complexType>
<xs:sequence>
<xs:element name="emp" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="row_id" type="xs:int" />
<xs:element name="emp_code" type="xs:string"
minOccurs="0" />
<xs:element name="emp_compdt"
minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern
value="|([0-3][0-9][\-](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[\-][0-9]{4})" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="emp_cdata" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="emp_cname"
type="xs:string" minOccurs="0" />
<xs:element name="emp_ccurr"
type="xs:string" minOccurs="0" />
<xs:element name="emp_camt" minOccurs="0" > <!-- ^\d+\.\d{0,2}$ -->
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+(\.[0-9][0-9]?)?" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Error which I am getting is Cannot find the declaration of element 'emp_comp'
what could be the reason for this.
Change:
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
To:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Then, provided that you do really have your XSD at http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd, it will work. Pull it up in a browser to be sure.
Problem
The problem is on first tag, remove this declaration xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd" and and fix <emp_compdt>01-APR-2014</emp_compdt>
Possible Solution
Define a namespace on XSD targetNamespace="http://namespace"
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://namespace">
<xs:element name="emp_comp">
<xs:complexType>
<xs:sequence>
<xs:element name="emp" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="row_id" type="xs:int" />
<xs:element name="emp_code" type="xs:string"
minOccurs="0" />
<xs:element name="emp_compdt"
minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern
value="|([0-3][0-9][\-](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[\-][0-9]{4})" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="emp_cdata" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="emp_cname"
type="xs:string" minOccurs="0" />
<xs:element name="emp_ccurr"
type="xs:string" minOccurs="0" />
<xs:element name="emp_camt" minOccurs="0" > <!-- ^\d+\.\d{0,2}$ -->
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+(\.[0-9][0-9]?)?" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
the XML could be
<ns1:emp_comp xmlns:ns1="http://namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://namespace http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-APR-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
</emp>
</ns1:emp_comp>
Ok, this might be first I am answering my own Question
<?xml version="1.0" encoding="UTF-8"?>
<emp_comp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost:9080/ermWeb/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-Jan-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
<emp_cdata>
<emp_cname>VPF</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>120.00</emp_camt>
</emp_cdata>
<emp_cdata>
<emp_cname>Employer NPS</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>130.00</emp_camt>
</emp_cdata>
<emp_cdata>
<emp_cname>Employee NPS</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>140.00</emp_camt>
</emp_cdata>
</emp>
</emp_comp>
there were 3 errors as they are pointed out by other answers.
1)01-04-2014 is incorrect, 04 must be replaced by APR
2)xmlns:xsi="http://www.w3.org/2001/XMLSchema" , must add -instance in the end
and
3) I need to use the XSD resource with the nameSpace ,to do that I have to add noNamespace before SchemaLocation in xsi:
Now XML is getting validated in accordance with XSD.
Related
I have the following XSD to validate this XML, but I don't know why it says that is valid. Notice that the pattern only checks for date, not date + time. Do you know how can I put a pattern to take only as valid the date + time? Thank you very much in advance.
XML:
<IN_PARAM>
<DATE_FROM>20/01/2018 10:35:00</DATE_FROM>
<DATE_TO>31/12/2019 18:40:00</DATE_TO>
</IN_PARAM>
XSD:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="IN_PARAM">
<xs:complexType>
<xs:sequence>
<xs:element name="DATE_FROM" minOccurs="1" maxOccurs="1" />
<xs:element name="DATE_TO" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DATE_FROM">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{2}/[0-9]{2}/[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DATE_TO">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{2}/[0-9]{2}/[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
I got it. You have to define a type, and that type must have the pattern do you want.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="IN_PARAM">
<xs:complexType>
<xs:sequence>
<xs:element name="DATE_FROM" type="DateTimeType" minOccurs="1" maxOccurs="1" />
<xs:element name="DATE_TO" type="DateTimeType" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="DateTimeType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{2}/[0-9]{2}/[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
And of course, if you need it, here is the pattern for dd/MM/yyyy hh:mm:ss:
<xs:pattern value="(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[0-9]{4} (0[0-9]|[1][0-9]|2[1-3]):([0-5][0-9]):([0-5][0-9])"/>
Requirement is read data from file and invoke webservice. Target webservice can handle one payload at a time but there will be multiple payload in source.
So am using while loop to process payload one by one.
Issue: In target service EarningTypeInclusion is optional element, so in source some payload this element will be present and in some payload this option element will not be present.
<thresholdRequestInterface xmlns:xs="http://www.sample.com/ns/LMSReferrals">
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
</thresholdRequest>
</thresholdRequestInterface>
If am using assign activity, then selection failure fault will come when optional elements are not present in source payload. We are using BPEL 10g, no option in assign activity to supress selection failure fault.
So decided to use transformation inside while loop .
logic used
Read from file
assign Loop counter=1
Count of payload(read from file)
While loop counter<= Count of payload
pass loop counter param value to transform
transform source i.e thresholdRequest[loopcounter] to target
Invoke target web service
increment loop counter
end loop;
Problem is same data is getting trsnformed.
In the below example, referral 11 data is loading 3 times. I have checked conter value, its getting incremented but inside transformation same values are getting transformed.
<thresholdRequestInterface xmlns:xs="http://www.sample.com/ns/LMSReferrals">
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
<thresholdRequest>
<Referral>12</Referral>
<thresholdValue>100</thresholdValue>
</thresholdRequest>
<thresholdRequest>
<Referral>13</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
</thresholdRequestInterface>
Source
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.sample.com/ns/LMSReferrals" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.sample.com/ns/LMSReferrals" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="thresholdRequestInterface">
<xs:complexType>
<xs:sequence>
<xs:element name="thresholdRequest" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Referral" type="xs:string"/>
<xs:element name="thresholdValue" type="xs:int"/>
<xs:element name="EarningTypeInclusion" minOccurs="0" maxOccurs="1" >
<xs:complexType>
<xs:sequence>
<xs:element name="earningType" type="xs:stirng" />
<xs:element name="ProvisionId">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Please find the schema structure for source and target
Target
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.sample.com/ns/LMSReferrals" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.sample.com/ns/LMSReferrals" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="thresholdRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Referral" type="xs:string"/>
<xs:element name="thresholdValue" type="xs:int"/>
<xs:element name="EarningTypeInclusion" minOccurs="0" maxOccurs="1" >
<xs:complexType>
<xs:sequence>
<xs:element name="earningType" type="xs:stirng" />
<xs:element name="ProvisionId">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Please note schema validation is enabled at target webservice.
Is there a specific reason that you are using Transform.Try using ora:getElement('/thresholdRequestInterface /thresholdRequest',bpws:getVariable(loopCounter))
I am trying to insert primary and foreign keys in XSD schema file below :-
Primary key is StudentID and Foreign Keys are courseID, AddressID, GradeID.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Student">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
<xs:element name="Dateborn" type="xs:date"/>
<xs:element name="Gender" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
However above code is not working in my setup please help me in tracing the issue,
In general you would need to put more details in a question... So this should be enough to understand what else you might need to define, and how. I'll tackle what's needed to understand how to define a primary key/foreign key by illustrating an assumed student/address relationship.
First you need to define a context where these constraints hold true. In my modified XSD, I call it the "World".
<?xml version="1.0" encoding="utf-8" ?>
<!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="World">
<xs:complexType>
<xs:sequence>
<xs:element ref="Student" maxOccurs="unbounded"/>
<xs:element ref="Address" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:key name="PKStudents">
<xs:selector xpath="Student/StudentID"/>
<xs:field xpath="."/>
</xs:key>
<xs:key name="PKAddresses">
<xs:selector xpath="Address/AddressID"/>
<xs:field xpath="."/>
</xs:key>
<xs:keyref name="FKStudentToAddress" refer="PKAddresses">
<xs:selector xpath="Student/AddressID"/>
<xs:field xpath="."/>
</xs:keyref>
</xs:element>
<xs:element name="Student">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
<xs:element name="Dateborn" type="xs:date"/>
<xs:element name="Gender" type="xs:string"/>
<xs:element name="StudentID" type="xs:string"/>
<xs:element name="AddressID" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:element name="AddressID" type="xs:string"/>
<xs:element name="Street" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
<xs:element name="Province" type="xs:string" minOccurs="0"/>
<xs:element name="Country" type="xs:date" minOccurs="0"/>
<xs:element name="PostalCode" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Then an XML like this would pass or fail, depending on what you do with the values in the StudentID and AddressID fields.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<World xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Student>
<Title>Title1</Title>
<FirstName>FirstName1</FirstName>
<LastName>LastName1</LastName>
<Dateborn>1900-01-01</Dateborn>
<Gender>Gender1</Gender>
<StudentID>StudentID1</StudentID>
<AddressID>AddressID1</AddressID>
</Student>
<Student>
<Title>Title1</Title>
<FirstName>FirstName1</FirstName>
<LastName>LastName1</LastName>
<Dateborn>1900-01-01</Dateborn>
<Gender>Gender1</Gender>
<StudentID>StudentID2</StudentID>
<AddressID>AddressID1</AddressID>
</Student>
<Address>
<AddressID>AddressID1</AddressID>
<Street>Street1</Street>
<City>City1</City>
<Province>Province1</Province>
<Country>1900-01-01</Country>
<PostalCode>PostalCode1</PostalCode>
</Address>
<Address>
<AddressID>AddressID2</AddressID>
<Street>Street1</Street>
<City>City1</City>
<Province>Province1</Province>
<Country>1900-01-01</Country>
<PostalCode>PostalCode1</PostalCode>
</Address>
</World>
To finish your solution, you would need to define the Course and Grade "entities" in your "world", define the xs:key for each, similar to Student/*Address*, then add CourseID and GradeID attributes to the entities that need them, and finally, define the keyref, as above, for Entity to Grade and Entity to Course.
I am creating a new web service in which the data format should have to made strict using XMLSchema. But I could not find a way to apply detail xml schema in Coldfusion web service
the web service is passing information as XML and they need to be in a strict format which sould be spedicied in the XML Schema , so that No wrong information is passed.
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="UpdatePendingTicketsRequest">
<xs:complexType>
<xs:sequence>
<xs:element ref="SIMS_REPLY_NAVISION_TO_INTOUCH">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UpdatePendingTicketsResponse">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="OK"/>
<xs:enumeration value="ERROR_PROCESSING"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:simpleType name="ST_STATUS">
<xs:restriction base="xs:integer">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
<xs:enumeration value="99"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="TRANSACTIONS">
<xs:complexType>
<xs:sequence>
<xs:element ref="TRANSACTION" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TRANSACTION">
<xs:complexType>
<xs:sequence>
<xs:element ref="ORIGINAL_TRANSACTION_ID"/>
<xs:element ref="STATUS"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="STATUS">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="ST_STATUS">
<xs:attribute name="description" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="DUPLICATE"/>
<xs:enumeration value="OK"/>
<xs:enumeration value="PROBLEM"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="SIMS_REPLY_NAVISION_TO_INTOUCH">
<xs:complexType>
<xs:sequence>
<xs:element ref="DATETIME"/>
<xs:element ref="TRANSACTIONS"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ORIGINAL_TRANSACTION_ID" type="xs:string"/>
<xs:element name="DATETIME" type="xs:dateTime"/>
<xs:element name="FaultStructure">
<xs:complexType >
<xs:sequence>
<xs:element type="xs:string" name="FaultCode"/>
<xs:element type="xs:string" name="FaultString"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
This is the sample XML Schema which is used to validate the payload. But when i create the same in Coldfusion, this is all i get.
<wsdl:types>
<schema targetNamespace="http://rpc.xml.coldfusion" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://xml.apache.org/xml-soap"/>
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="CFCInvocationException">
<sequence/>
</complexType>
</schema>
</wsdl:types>
I did a lot of search and never found a concrete solution for it.
This might not be answer but I always recommend that do not build webservice in ColdFusion to receive xml document as arguments. Instead use xml string as argument which later you can convert to xml document using xmlParse(). I had such experience in past and later I need to convert it to xml string argument.
Thanks
Pritesh
I've got the following two XSL transforms that I would like to chain together in one XSL file.
The first transform:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:template match="/">
<xsl:copy-of select="/s0:definitions/s0:types/xs:schema"/>
</xsl:template>
</xsl:stylesheet>
And the second transform (using the output of the first as input):
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/xs:schema/xs:element[#name='ServiceAuth']"/>
<xsl:template match="/xs:schema/xs:import[#namespace='http://www.somecompany.com/serviceAuth/ ']"/>
</xsl:stylesheet>
What I'm aiming to accomplish with this, is to copy only the xs:schema node (and all it's children) from a WSDL whilst at the same time removing two nodes from inside the xs:schema node.
How do I chain these two together in one XSL or is there an even better way to accomplish the above objective?
Below is the WSDL input file that should serve as input to the first transform:
<s0:definitions name="CBS_GetUpgradeEligibility" targetNamespace="http://www.somecompany.com/" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:s2="http://www.somecompany.com/" xmlns:s3="http://schemas.xmlsoap.org/wsdl/soap/">
<s0:types>
<xs:schema targetNamespace="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:auth="http://www.somecompany.com/serviceAuth/" xmlns:cbs="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:esb="http://www.somecompany.com/esbTypes/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.somecompany.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.somecompany.com/esbTypes/" schemaLocation="http://127.0.0.1:5000/CBS_GetUpgradeEligibility?SCHEMA%2FVodacom+Services%2FInfrastructure+Services%2FSchemas%2FXSD_ESBTypes"/>
<xs:import namespace="http://www.somecompany.com/serviceAuth/ " schemaLocation="http://127.0.0.1:5000/CBS_GetUpgradeEligibility?SCHEMA%2FVodacom+Services%2FInfrastructure+Services%2FSchemas%2FXSD_ServiceAuth"/>
<xs:simpleType name="DESTINATION_MSISDN">
<xs:restriction base="xs:string">
<xs:maxLength value="11"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_13">
<xs:restriction base="xs:string">
<xs:maxLength value="13"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_20">
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="UPGRADE_TYPE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isber" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="isreward" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="code" type="cbs:STRING_20"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QUALIFIES_FOR_UPGRADE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isaveragespentmet" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="is7daypremature" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="upgradepossible" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="1" name="upgradeduedate" type="cbs:STRING_13"/>
<xs:element maxOccurs="1" minOccurs="0" name="UpgradeType" type="cbs:UPGRADE_TYPE_DETAILS"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ServiceAuth">
<xs:complexType>
<xs:sequence>
<xs:element name="Username" type="auth:Username"/>
<xs:element name="Password" type="auth:Password"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetUpgradeEligibilityRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="TSORequest" type="cbs:getUpgradeEligibilityRequestElement"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetUpgradeEligibilityResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="TSOID" type="esb:TSOID"/>
<xs:element name="TSOResponse" type="cbs:getUpgradeEligibilityResponseElement"/>
<xs:element maxOccurs="1" minOccurs="1" name="TSOResult" type="esb:TSOResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="getUpgradeEligibilityRequestElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUpgradeEligibilityResponseElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"/>
<xs:element maxOccurs="1" minOccurs="1" name="QualifiesForUpgrade" type="cbs:QUALIFIES_FOR_UPGRADE_DETAILS"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</s0:types>
<s0:message name="GetUpgradeEligibilityRequestMessage">
<s0:part element="s1:ServiceAuth" name="ServiceAuth"/>
<s0:part element="s1:GetUpgradeEligibilityRequest" name="GetUpgradeEligibilityRequest"/>
</s0:message>
<s0:message name="GetUpgradeEligibilityResponseMessage">
<s0:part element="s1:GetUpgradeEligibilityResponse" name="GetUpgradeEligibilityResponse"/>
</s0:message>
<s0:portType name="esbTransactionPort">
<s0:operation name="getUpgradeEligibility">
<s0:input message="s2:GetUpgradeEligibilityRequestMessage"/>
<s0:output message="s2:GetUpgradeEligibilityResponseMessage"/>
</s0:operation>
</s0:portType>
<s0:binding name="getUpgradeEligibilityEsbTransactionBinding" type="s2:esbTransactionPort">
<s3:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<s0:operation name="getUpgradeEligibility">
<s3:operation soapAction="" style="document"/>
<s0:input>
<s3:header message="s2:GetUpgradeEligibilityRequestMessage" part="ServiceAuth" use="literal"/>
<s3:body parts="GetUpgradeEligibilityRequest" use="literal"/>
</s0:input>
<s0:output>
<s3:body parts="GetUpgradeEligibilityResponse" use="literal"/>
</s0:output>
</s0:operation>
</s0:binding>
<s0:service name="getUpgradeEligibilityEsbTransactionBindingQSService">
<s0:port binding="s2:getUpgradeEligibilityEsbTransactionBinding" name="getUpgradeEligibilityEsbTransactionBindingQSPort">
<s3:address location="http://VESB14-PRD:7701/CBS_GetUpgradeEligibility"/>
</s0:port>
</s0:service>
</s0:definitions>
If you want a third stylesheet that compose those two performing the same transformation as:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="s0:definitions/s0:types/xs:schema"/>
</xsl:template>
<xsl:template match="xs:schema/xs:element[#name='ServiceAuth']"/>
<xsl:template match="xs:schema/xs:import[#namespace='http://www.somecompany.com/serviceAuth/']"/>
</xsl:stylesheet>
Then you need:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:import href="stylesheet2.xsl"/>
<xsl:import href="stylesheet1.xsl"/>
<xsl:template match="/">
<xsl:variable name="vFirst">
<xsl:apply-imports/>
</xsl:variable>
<xsl:apply-templates select="msxsl:node-set($vFirst)/node()"/>
</xsl:template>
</xsl:stylesheet>
Output:
<xs:schema targetNamespace="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:s2="http://www.somecompany.com/" xmlns:s3="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:auth="http://www.somecompany.com/serviceAuth/" xmlns:cbs="http://www.somecompany.com/CBS_GetUpgradeEligibility/" xmlns:esb="http://www.somecompany.com/esbTypes/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.somecompany.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.somecompany.com/esbTypes/" schemaLocation="http://127.0.0.1:5000/CBS_GetUpgradeEligibility?SCHEMA%2FVodacom+Services%2FInfrastructure+Services%2FSchemas%2FXSD_ESBTypes"></xs:import>
<xs:simpleType name="DESTINATION_MSISDN">
<xs:restriction base="xs:string">
<xs:maxLength value="11"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_13">
<xs:restriction base="xs:string">
<xs:maxLength value="13"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STRING_20">
<xs:restriction base="xs:string">
<xs:maxLength value="20"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="UPGRADE_TYPE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isber" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="isreward" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="code" type="cbs:STRING_20"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="QUALIFIES_FOR_UPGRADE_DETAILS">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="isaveragespentmet" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="is7daypremature" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="upgradepossible" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="upgradeduedate" type="cbs:STRING_13"></xs:element>
<xs:element maxOccurs="1" minOccurs="0" name="UpgradeType" type="cbs:UPGRADE_TYPE_DETAILS"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="GetUpgradeEligibilityRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="TSORequest" type="cbs:getUpgradeEligibilityRequestElement"></xs:element>
</xs:sequence>
</xs:complexType></xs:element>
<xs:element name="GetUpgradeEligibilityResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="TSOID" type="esb:TSOID"></xs:element>
<xs:element name="TSOResponse" type="cbs:getUpgradeEligibilityResponseElement"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="TSOResult" type="esb:TSOResult"></xs:element>
</xs:sequence>
</xs:complexType></xs:element>
<xs:complexType name="getUpgradeEligibilityRequestElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getUpgradeEligibilityResponseElement">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="MSISDN" type="cbs:DESTINATION_MSISDN"></xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="QualifiesForUpgrade" type="cbs:QUALIFIES_FOR_UPGRADE_DETAILS"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
I haven't touched XSLT for quite some time - but I think you can do it iterativly instead of by applying templates.
Start by selecting /s0:definitions/s0:types/xs:schema - then go over all of it's children (<xsl:for-each ... If i recall correctly) and for each of them test if it is the node you want to omit. if not - use copy-of, otherwise just drop it
Also, if you run the XSLT using some java code, or ANY utility you can just pass the output of the 1st XSLT as the input of the 2nd XSLT.
Hope this helps.
Since the first stylesheet is just selecting what is processed by the 2nd -- not doing any transformation itself, can't you just change copy-of to apply-templates, and import the 2nd stylesheet ? ( You don't really need to do any chaining. )
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/">
<xsl:import href="stylesheet-2.xsl" />
<xsl:template match="/">
<xsl:apply-templates select="/s0:definitions/s0:types/xs:schema"/>
</xsl:template>
</xsl:stylesheet>