on 03-08-2006 1:43 PM - last edited on 02-03-2024 7:25 PM by postmig_api_4
Hello together!
I have the following problem. I have incoming XML messages and I want to validate this message against the matching XSD.
I have seen in a sun forum that I can validate the message with a DOM Parser :
/message/928947#928947 [original link is broken]
import org.apache.xerces.parsers.DOMParser;
import java.io.File;
import org.w3c.dom.Document;
public class SchemaTest
{
public static void main (String args[])
{
File docFile = new File("memory.xml");
try
{
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"memory.xsd");
ErrorChecker errors = new ErrorChecker();
parser.setErrorHandler(errors);
parser.parse("memory.xml");
}
catch (Exception e)
{
System.out.print("Problem parsing the file.");
}
}
}
But, in which directory on the XI or place can I do the XSD file to do a validation??
Thanks a lot
ciao Alex
Bhavesh, Ananth,
thank you very much for the fast responses!! I will try it!
ciao Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Ananth,
for the moment I am not sure: does everybody have an access to this directory or just the responsible persons which work with that directory on XI??
Thanks a lot
ciao Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
No, Normally XI BASIS/Admin people have access to Server directories. And moreover AFAIK, XI validates your Incoming messages based on your Data type definition, so I dont think that explicit validation is required.
But if you want to do so then you have to store the XSD file in XI server directory and refer it in source XML.
regards,
Ananth
Hi Alexander,
You can place the XSD files in the following location
/usr/sap/XISRV/DVEBMGS**/j2ee/cluster/server0/
and refer the same in XML like this..
<?xml version="1.0"?>
<MSG
xmlns="http://www.abc.com"
xmlns:xsi="http://www.abc.org/XMLSchema-instance"
xsi:schemaLocation="locationURL YourXSD.xsd">
<Abc>
<Bbc>XYZ</Bbc>
</Abc>
</MSG>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
In XI, you can do a validation of your XML in your Mapping by creating a Java Mapping.
As you have mentioned that you are using a DOM Parser, i think this link can help you a lot <a href="http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html">DOM Parser Methods</a>.
Also, you can develop your Java Mapping code, and then use import it as a JAR under IMPORTED ARCHIVES in your MAPPING OBJECTS.
Hope this helps,
Regards,
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.