cancel
Showing results for 
Search instead for 
Did you mean: 

Along with Namespace require others atr like xmlns:xsi & xsi:schemaLocation

Former Member
0 Kudos

Hi Experts,

Could you please help me in creation of the XSD so that the output file from PI will contain the following message:

Message xmlns="http://www.abc.com/schemas/" xmlns:xsi="http://www.w3.org/Schema-instance" xsi_schemaLocation="http://www.abc.com/schemas/ http://www.abc.com/schemas/4.0.0/2001/message.xsd"; >

Accepted Solutions (0)

Answers (1)

Answers (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You need to use Java Mapping or XSLT Mapping to append

 xmlns="http://www.abc.com/schemas/" xmlns:xsi="http://www.w3.org/Schema-instance" xsi_schemaLocation="http://www.abc.com/schemas/ http://www.abc.com/schemas/4.0.0/2001/message.xsd"

to the field Message.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Experts,

As i said my requirement is to include the following in the output XML.

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation =="http://www.XYZ.com/schemas/ http://www.XYZ.com/schemas/4.0.0/2001/message.xsd">

i have written the XSD as below

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.XYZ.com/schemas/"
	xmlns="http://www.XYZ.com/schemas/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xsi:schemaLocation="http://www.XYZ.com/schemas/ http://www.XYZ.com/schemas/4.0.0/2001/message.xsd">
	<xsd:element name="Message" type="Message" />
	<xsd:complexType name="Message">
		<xsd:sequence>
			<xsd:element name="Head">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="field1">
							<xsd:complexType>
								<xsd:attribute name="Id" type="xsd:string" />
							</xsd:complexType>
						</xsd:element>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
</xsd:schema>

but when the correponding XML from this XSD donot have the

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation =="http://www.XYZ.com/schemas/ http://www.XYZ.com/schemas/4.0.0/2001/message.xsd">

Any clue , how to handle this.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Yup, I stick with my previous answer. This is possible to achieve via Java mapping or XSLT mapping. Your requirement is almost similar to importing the xsds from gs1.org. Even though there are multiple namespaces declared in the xsd, only the targetNamespace is appearing.

I have not tried using the XMLAnonymizer Bean for adding namespaces. Let us wait for the replies of others

Hope this helps,

Mark

udo_martens
Active Contributor
0 Kudos

Hi,

this is not easy to handle with creating a XML schema for exteranl message type and a message mapping.

A XSL stylesheet would be much easier, you dont need an exact data type (use a data type with a dummy field).

Just write down the target message as you like it, exaclty with that strange namespaces and attributes and add the field values dynamicly with xsl:value-of. For repeating fields use xsl:for-each.

Regards,

Udo

Former Member
0 Kudos

Thanks Mark,Udo.

i have used a simple java mapping to solve this.