Skip to Content
avatar image
Former Member

XML Schema in PI 7.0

Hi...

Can anyone tell me about how to validate the schemas in PI 7.0.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 01, 2008 at 12:56 PM

    http://72.14.235.104/search?q=cache:xXUqSuBD2BIJ:https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d06dff94-9913-2b10-6f82-9717d9f83df1validatetheschemasinSAPPI&hl=en&ct=clnk&cd=1&lr=lang_en

    ur answer

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 01, 2008 at 02:32 PM

    hi leela,

    you can write an adapter module, for validating schemas in PI7.0

    regards,

    Madhav

    Add comment
    10|10000 characters needed characters exceeded

    • Here is the method validation which you can use in adapter module .

      Use SAX /DOM parsing to prepare the output document if any change is required for the output file structure after validation.or else if the file is valid just send the inputstream as it is as the output (SAX is a better option for changing structure)

      The code is to validate the xml with no namespace schema location .please palce the xsd on server inside usr/sap/<SID>/DVE/j2ee/cluster/server0 folder

      
      public boolean validateXml(byte[] xmlName)
      	{
      		// preparing the XML file as a input source
      		InputSource source =
      			new InputSource(new java.io.ByteArrayInputStream(xmlName));
      		//String parserClass = "org.apache.xerces.parsers.SAXParser";
      		String parserClass = "com.sap.engine.lib.xml.parser.SAXParser";
      		String validationFeature = "http://xml.org/sax/features/validation";
      		String schemaFeature =
      			"http://apache.org/xml/features/validation/schema";
      		//String namespacesFeature = "http://xml.org/sax/features/namespaces";
      		//String noNamespaceProperty ="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
      		//String dynamicFeature = "http://apache.org/xml/features/validation/dynamic";
      		
      		//XMLValidationBean vl = new XMLValidationBean();
      		try
      		{
      			XMLReader r = XMLReaderFactory.createXMLReader(parserClass);
      			r.setFeature(validationFeature, true);
      			//r.setFeature(namespacesFeature,true);
      			//r.setFeature(dynamicFeature,true);
      			r.setFeature(schemaFeature, true);
      			r.setErrorHandler(this);
      //			
      //			if(checkOrderType(xmlName))
      //			r.setProperty( "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" , "EDItX_TradeOrder_V1.1.xsd");
      //			else
      //			r.setProperty( "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" , "abc.xsd");
      //			
      			r.parse(source);
      			
      			//System.out.println("ValidateXML :" + isValid);
      		}
      		catch (SAXException e)
      		{
      			isValid = false;
      			Audit.addAuditLogEntry(
      				myAuditMsgKey,
      				AuditLogStatus.ERROR,
      				"Exception : " + e.getCause());
      		}
      		catch (IOException e)
      		{
      			Audit.addAuditLogEntry(
      				myAuditMsgKey,
      				AuditLogStatus.ERROR,
      				"Exception : " + e.getMessage());
      		}
      		catch (Throwable e)
      		{
      			Audit.addAuditLogEntry(
      				myAuditMsgKey,
      				AuditLogStatus.ERROR,
      				"Exception : " + e.getMessage());
      		}
      		//Audit.flushAuditLogEntries(myAuditMsgKey);
      		return isValid;
      	}
      

      Edited by: Progirl Progirl on Jul 2, 2008 6:41 AM

  • avatar image
    Former Member
    Jul 01, 2008 at 01:17 PM

    I think you need PI 7.1 for schema validation.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 01, 2008 at 02:16 PM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 02, 2008 at 05:25 AM

    Hi,

    To validate xml from source side with the help of Adapter modules in XI.

    Similarly we can handle any type schema validation with xml validation tools or xml schema conversion tools.

    The same concept will be used to convert the source schema into valid XI xml schema ( Edi message to normal xml)

    Also we can use Java mapping (SAX for structure changes) to validate schema itself.

    Check the below links for more details

    http://www.xmlconverters.com/customers/sap-review.html

    On how to create XML docs with SAX and DOM go thruugh these links:

    http://www.cafeconleche.org/books/xmljava/chapters/ch09.html

    http://www.cafeconleche.org/books/xmljava/chapters/ch06.html

    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm

    DOM parser API

    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html

    Add comment
    10|10000 characters needed characters exceeded