2 Replies Latest reply: Jul 21, 2014 4:18 AM by 1003805 RSS

    Validating the request using Schematron file in mediator

    1003805

      Hi All,

      My requirement is "validating the incoming request using  schemetron file(.sch) in mediator.

      for the above requirement  I have tried  as below:

      Providing the input from the Syncronous mediator and output should write in file adapter.

      I created the schemetron file for validating the input request which is shown below:

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

      <schema xmlns="http://www.ascc.net/xml/schematron">

        <pattern name="sal validation">

          <rule context="Employee/Employedetails">

            <assert test="sal > 15000">salary should be greater than 15000</assert>

          </rule>

        </pattern>

      </schema>

       

      My schema is as follows:


      <xsd:element name="Employee">

          <xsd:complexType>

            <xsd:sequence>

              <xsd:element name="Employedetails" maxOccurs="unbounded">

                <xsd:complexType>

                  <xsd:sequence>

                    <xsd:element name="empname" type="xsd:string"/>

                    <xsd:element name="depno" type="xsd:string"/>

                    <xsd:element name="sal" type="xsd:int"/>

                  </xsd:sequence>

                </xsd:complexType>

              </xsd:element>

            </xsd:sequence>

          </xsd:complexType>

        </xsd:element>

      The problem here is i am able to deploy the project . while testing ,it not validating the sal.i.e(if sal>15000 and sal<15000 is getting validated).

      Can someone explain me what's the mistake am making here and a solution to complete this requirement successfully?

      Appreciate your help.



      Regards,

      Teja

        • 1. Re: Validating the request using Schematron file in mediator
          Dhaval Parikh-Oracle

          Hi,

           

          Please provide complete XPATH in the Assert "<assert test="sal > 15000">salary should be greater than 15000</assert>"

           

          e.g. <assert test="/Employee/Employedetails/sal > 15000">salary should be greater than 15000</assert>

          • 2. Re: Validating the request using Schematron file in mediator
            1003805

            Hi Dhaval,

            Thanks for spending your valuable time.

            After providing the complete xpath.it is not able to validating the sal.

            I have tried with another sample by taking different schema and adding @namespace in schematron file

            My Schema file

             

            <?xml version="1.0" encoding="windows-1252" ?>

            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

                        xmlns="http://www.example.org"

                        targetNamespace="http://www.example.org"

                        elementFormDefault="qualified">

              <xsd:element name="input">

                <xsd:complexType>

                  <xsd:sequence>

                    <xsd:element name="empno" type="xsd:string"/>

                    <xsd:element name="empname" type="xsd:string"/>

                    <xsd:element name="sal" type="xsd:int"/>

                  </xsd:sequence>

                </xsd:complexType>

              </xsd:element>

            </xsd:schema>

             

            Schemetron file for validating the input request which is shown below:

             

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

            <schema xmlns="http://www.ascc.net/xml/schematron">

            <ns uri="http://www.example.org" prefix="a"/>

              <pattern name="sal validation">

                <rule context="a:input">

                  <assert test="a:sal &gt; 10000">sal  should be greater than 10000</assert>

                </rule>

              </pattern>

            </schema>

             

            The schematron file is working fine and sal is getting validated as per the given inputs.

             

            Regards,

            Teja.