cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping - namespace problem?

Former Member
0 Kudos

Hello,

I am trying to proces a message with the following format:

<XMLMESSAGE xsi:nonamespaceSchemalocation='schema.xsd' >

<ORDER>

<HEADER>

......

</HEADER>

<ITEM>

.....

</ITEM

</ORDER>

<XMLMESSAGE>

the mapping (XSLT or message mapping) throws an exception. During runtime or test, this is the same.

The problem occurs, I think, because of the nonamespace atriibute. If a change or remove the value, the mapping is fine.

Does anybody know if I should save the file mentioned in the attribute somewhere? Or is there a workaround for this problem?

thnx, Paul

PS: we are using PI 7.0.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Paul,

Your input XML has a dtd declaration. The XML parser is trying to resolve the DTD location. In your

case, you are getting an java.net.UnknownHostException: www.oasis-open.org.

You can test this by downloading the file http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent

and placing it on your server. Then change the location in the XML:


<!DOCTYPE ORDER [
<!ENTITY % iso-lat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML" "file:///tmp/iso-lat1.ent">
%iso-lat1;
]>

You may not have the ability to change the location of the DTD in your input message. I think if your

server had network access to www.oasis-open.org it would work. If that is not an option either, you could start a new thread asking specifically about either ignoring the DTD declaration in an XML message or overriding the DTD location. If all else fails, you can always send it into a java mapping first

to remove the DTD declaration.

Thanks,

-Russ

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Russ (and others),

I tested it in the real example, but it still throws the same error on the java (=compiled) mapping.

this is my input:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ORDER [
<!ENTITY % iso-lat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML" "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent">
%iso-lat1;
]>
<XMLMESSAGE xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="OrderBericht.xsd">
	<ORDER>
		<HEADER>
			<ACCOUNT_NUMBER></ACCOUNT_NUMBER>
		</HEADER>
		<LINE_ITEMS>
			<ITEM>
				<LINE>1</LINE>
			</ITEM>
		</LINE_ITEMS>
	</ORDER>
</XMLMESSAGE>

this is my xslt:


<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" standalone="no" indent="yes"/>
 	<xsl:template match="/">
		<ORDERS05 xmlns="com:root">
			<IDOC BEGIN="1">
		    	<xsl:call-template name="CrtEDIDC40"/>
			</IDOC>
		</ORDERS05>
	</xsl:template>
	<xsl:template name="CrtEDIDC40">
		<EDI_DC40 SEGMENT="1">
			<TABNAM>EDI_DC40</TABNAM>
			<SNDPRT>LS</SNDPRT>
			<SNDPRN>XIDCLNT300</SNDPRN>
		</EDI_DC40>
	</xsl:template>
</xsl:stylesheet>

and this is the error:


18:00:41 Start of test
Creating XSLT mapping mindef_test
Call XSLT processor with stylsheet mindef_test.xsl.
Method error called terminate transformation
javax.xml.transform.TransformerException: IOException occurred while parsing stream. An empty document will be used! at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:351) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.io.IOException: Failed to load resource from the context classloader of the current thread! Loading from classloader was caused by: java.net.UnknownHostException: www.oasis-open.org at com.sap.engine.lib.xml.parser.URLLoaderBase.resolveEntity(URLLoaderBase.java:148) at com.sap.engine.lib.xml.parser.helpers.AdvancedXMLStreamReader.addInputFromEntity(AdvancedXMLStreamReader.java:393) at com.sap.engine.lib.xml.parser.XMLParser.handleDTDReference(XMLParser.java:2267) at com.sap.engine.lib.xml.parser.XMLParser.scanIntSubset(XMLParser.java:1057) at com.sap.engine.lib.xml.parser.XMLParser.scanDTD(XMLParser.java:1246) at com.sap.engine.lib.xml.parser.XMLParser.scanProlog(XMLParser.java:2795) at com.sap.engine.lib.xml.parser.XMLParser.scanDocument(XMLParser.java:2830) at com.sap.engine.lib.xml.parser.XMLParser.parse0(XMLParser.java:229) at com.sap.engine.lib.xml.parser.AbstractXMLParser.parseAndCatchException(AbstractXMLParser.java:145) at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:160) at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:261) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:347) ... 19 more --------- java.io.IOException: Failed to load resource from the context classloader of the current thread! Loading from classloader was caused by: java.net.UnknownHostException: www.oasis-open.org at com.sap.engine.lib.xml.parser.URLLoaderBase.resolveEntity(URLLoaderBase.java:148)

any ideas? I am totally lost here.

Former Member
0 Kudos

Hi Russ,

I implemented your test example and it does seem to work. Tomorrow I will try to implement your settings from the XSL in the real mapping and see if this actually solves the problem.

thank you for your help,

Paul

Former Member
0 Kudos

Hi Paul,

I ran a quick test based on what you sent in. This simplified test is just to see how the noNamespaceu2026

is handled. The following works on our system. Perhaps you can set this up as well and see if you get

the same error.

Input:


<?xml version="1.0" encoding="utf-8"?>
<XMLMESSAGE xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="OrderBericht.xsd">
  <ORDER>
    <HEADER>
      <test>1</test>
    </HEADER>
    <ITEM>
      <test>2</test>
    </ITEM>
  </ORDER>
</XMLMESSAGE>

xsl:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" standalone="no" indent="yes"/>
  <xsl:template match="/">
    <root xmlns="com:example">
      <header>
        <test><xsl:value-of select="/XMLMESSAGE/ORDER/HEADER/test"/></test>
      </header>
      <items>
        <test><xsl:value-of select="/XMLMESSAGE/ORDER/ITEM/test"/></test>
      </items>
    </root>
  </xsl:template>
</xsl:stylesheet>

Output:


<?xml version="1.0" encoding="utf-8"?>
<root xmlns="com:example">
  <header>
    <test>1</test>
  </header>
  <items>
    <test>2</test>
  </items>
</root>

-Russ

prateek
Active Contributor
0 Kudos

What does xsi here refer to? It should be something like

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceSchemalocation="'schema.xsd"

Also enclose schema.xsd with double quotes.

Regards,

Prateek

Former Member
0 Kudos

the incoming xml has this:

<XMLMESSAGE xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="OrderBericht.xsd">

the test mapping looks like:

Value

[ ] XMLMESSAGE

noNamespaceSchemaLocation OrderBericht.xsd

the mapping fails with this information. If you remove the value for the atrribute, the mapping runs fine again.

Paul