cancel
Showing results for 
Search instead for 
Did you mean: 

XML Schema in PI 7.0

Former Member
0 Kudos

Hi...

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (4)

Answers (4)

Former Member
0 Kudos

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

Former Member
0 Kudos

hi leela,

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

regards,

Madhav

Former Member
0 Kudos

Hi Madhav.

Is there no other option other than writing adapter module for validating schemas.

former_member859847
Active Contributor
0 Kudos

Hi,

you have this option in PI 7.1.

in order to validate incoming xsd schema,please prepare one java program.

call the java program & message mapping at interface mapping.

java program compare the incoming XSD schema with Pre-defined Message type schema.

warm regards

mahesh.

former_member190389
Active Contributor
0 Kudos

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

Former Member
0 Kudos
Former Member
0 Kudos

I think you need PI 7.1 for schema validation.