cancel
Showing results for 
Search instead for 
Did you mean: 

Enterprise Service Generate Message types basing on XML-file (file adapter)

florian_finauer2
Explorer
0 Kudos

Hello together,

Using file adapter as inbound  I have following situation: I get a special XML-file format (unfortunately it is not possible to get the corresponding XSD) and I have to generate a message type for it: The XML looks like this:

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'

xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'

xmlns:rs='urn:schemas-microsoft-com:rowset'

xmlns:z='#RowsetSchema'>

<s:Schema id='RowsetSchema'>

<s:ElementType name='row' content='eltOnly' rs:updatable='true'>

  <s:AttributeType name='Fahrzeug' rs:number='1' rs:nullable='true' rs:write='true' rs:writeunknown='true'>

   <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>

  </s:AttributeType>

  <s:AttributeType name='c1' rs:name='G Logical ID' rs:number='2' rs:nullable='true' rs:write='true' rs:writeunknown='true'>

   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

  </s:AttributeType>

  <s:AttributeType name='c2' rs:name='G Cumm Motion' rs:number='3' rs:nullable='true' rs:write='true' rs:writeunknown='true'>

   <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>

  </s:AttributeType>

  <s:AttributeType name='c3' rs:name='G Last Detected' rs:number='4' rs:nullable='true' rs:write='true' rs:writeunknown='true'>

   <s:datatype dt:type='dateTime' rs:dbtype='timestamp' dt:maxLength='16' rs:scale='3' rs:precision='23' rs:fixedlength='true'/>

  </s:AttributeType>

  <s:extends type='rs:rowbase'/>

</s:ElementType>

</s:Schema>

<rs:data>

<z:row Fahrzeug='00780' c1='780' c2='36218' c3='2012-01-23T14:31:34'/>

<z:row Fahrzeug='18395' c1='1002' c2='718480' c3='2012-03-23T19:24:50'/>

</rs:data>

</xml>

If I generate data types now it is not possible to use names like "rs:data" or "rs:row" and so on.

Error:

Value "rs:row" is not allowed for attribute "name" of type "NCName" in element "/schema/complexType("DT_MeasurementData")/sequence/element("data")/complexType/sequence/element("rs:row")"

What can I do? I also do not manage to generate a XSD from this XML by using tools like XMLSpy.

Thanks for your help,

Florian

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi,

Use for instance this online tool (first google result for "generate xsd from xml online") to generate an xsd file for your XML message: http://www.xmlforasp.net/codebank/system_xml_schema/buildschema/buildxmlschema.aspx. I just tried it out on your message and it seemed to work well.

Hope this helps,

Greg

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

Hi Florian,

Correct me if i'm wrong. When you says that you are using File Adapter as inbound i suppose that you are using a Receiver File Adapter. The problem is basically that you can't import that schema in PI. If you don't want to search the way that PI schema importing accepts the schema you could use a XSL mapping, you don't really need to import the schema, you could import a dummy schema  and later in operation mapping to use a XSL transformation, PI won't try to check it.

Regards.

florian_finauer2
Explorer
0 Kudos

HI together,

@Greg: Thank you for this link -very usefull. Unfortunatly if I generate the XSD-file and import it in PI I get errror messages:

 
Cause: Theu uploaded document has no valid XML format

  
Error parsing the XML document com.sap.aii.utilxi.xml.xdom.XDOMException$ParseError: Error parsing t...

@Inaki: No - my scenario is sender file adapter to ABAP Proxy. So I get the XML in the format above. Therefore I need a message type or external definition (XSD) of the XML-file. Or is it possible to generate a XSLT for this XML? I want to do the mapping in graphical editor.

What can I do?

Thanks a lot,

Florian

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might want to validate xml against xsd using XMLSPY tool or some online tool as below

http://www.freeformatter.com/xml-validator-xsd.html

iaki_vila
Active Contributor
0 Kudos

Hi Florian,

The best way is try to create the XSD with the tools indicated by Baskar or Grzegorz. With the XMLSPY i've tried to create an XSD with your xml example, i've obtained four files, the PI importing hasn't had any problems but later i have had problems because PI doesn't recognize any element as message sructure.

I've proposed another way, in your File-Proxy ABAP scenario like you mentioned above is necessary an schema in the receiver side, but the XSD in the receiver side can be how you need, for example, i want to say that you could have a XSD with only one namespace and to map the values in a XML target with a structure less complex or can't you change the receiver schema?

Regards.

iaki_vila
Active Contributor
0 Kudos

Hi Florian,

I've tested this morning this:

1. I make an xsl to eliminate all namespaces:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

          <xsl:output method="xml" indent="no"/>

          <xsl:template match="/|comment()|processing-instruction()">

                    <xsl:copy>

                              <xsl:apply-templates/>

                    </xsl:copy>

          </xsl:template>

          <xsl:template match="*">

                    <xsl:element name="{local-name()}">

                              <xsl:apply-templates select="@*|node()"/>

                    </xsl:element>

          </xsl:template>

          <xsl:template match="@*">

                    <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>

          </xsl:template>

</xsl:stylesheet>

2. I tested this xsl and i obtain this xml:

<?xml version="1.0" encoding="UTF-8"?>

<xml>

          <Schema id="RowsetSchema">

                    <ElementType name="row" content="eltOnly" updatable="true">

                              <AttributeType name="Fahrzeug" number="1" nullable="true" write="true" writeunknown="true">

                                        <datatype type="string" dbtype="str" maxLength="50"/>

                              </AttributeType>

                              <AttributeType name="G Logical ID" number="2" nullable="true" write="true" writeunknown="true">

                                        <datatype type="int" maxLength="4" precision="10" fixedlength="true"/>

                              </AttributeType>

                              <AttributeType name="G Cumm Motion" number="3" nullable="true" write="true" writeunknown="true">

                                        <datatype type="int" maxLength="4" precision="10" fixedlength="true"/>

                              </AttributeType>

                              <AttributeType name="G Last Detected" number="4" nullable="true" write="true" writeunknown="true">

                                        <datatype type="dateTime" dbtype="timestamp" maxLength="16" scale="3" precision="23" fixedlength="true"/>

                              </AttributeType>

                              <extends type="rs:rowbase"/>

                    </ElementType>

          </Schema>

          <data>

                    <row Fahrzeug="00780" c1="780" c2="36218" c3="2012-01-23T14:31:34"/>

                    <row Fahrzeug="18395" c1="1002" c2="718480" c3="2012-03-23T19:24:50"/>

          </data>

</xml>

3. With XMLSPY tool i generate the xsd:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!--W3C Schema generated by XMLSpy v2005 rel. 3 U (http://www.altova.com)-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

          <xs:element name="AttributeType">

                    <xs:complexType>

                              <xs:sequence>

                                        <xs:element ref="datatype"/>

                              </xs:sequence>

                              <xs:attribute name="name" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:string">

                                                            <xs:enumeration value="Fahrzeug"/>

                                                            <xs:enumeration value="G Cumm Motion"/>

                                                            <xs:enumeration value="G Last Detected"/>

                                                            <xs:enumeration value="G Logical ID"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="number" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:string">

                                                            <xs:enumeration value="1"/>

                                                            <xs:enumeration value="2"/>

                                                            <xs:enumeration value="3"/>

                                                            <xs:enumeration value="4"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="nullable" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:boolean">

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="write" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:boolean">

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="writeunknown" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:boolean">

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                    </xs:complexType>

          </xs:element>

          <xs:element name="datatype">

                    <xs:complexType>

                              <xs:attribute name="type" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:string">

                                                            <xs:enumeration value="dateTime"/>

                                                            <xs:enumeration value="int"/>

                                                            <xs:enumeration value="string"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="dbtype">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:string">

                                                            <xs:enumeration value="str"/>

                                                            <xs:enumeration value="timestamp"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="maxLength" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:byte">

                                                            <xs:enumeration value="16"/>

                                                            <xs:enumeration value="4"/>

                                                            <xs:enumeration value="50"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="precision">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:string">

                                                            <xs:enumeration value="10"/>

                                                            <xs:enumeration value="23"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="fixedlength">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:boolean">

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="scale">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:byte">

                                                            <xs:enumeration value="3"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                    </xs:complexType>

          </xs:element>

          <xs:element name="row">

                    <xs:complexType>

                              <xs:attribute name="Fahrzeug" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:string">

                                                            <xs:enumeration value="00780"/>

                                                            <xs:enumeration value="18395"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="c1" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:short">

                                                            <xs:enumeration value="1002"/>

                                                            <xs:enumeration value="780"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="c2" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:int">

                                                            <xs:enumeration value="36218"/>

                                                            <xs:enumeration value="718480"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                              <xs:attribute name="c3" use="required">

                                        <xs:simpleType>

                                                  <xs:restriction base="xs:dateTime">

                                                            <xs:enumeration value="2012-01-23T14:31:34"/>

                                                            <xs:enumeration value="2012-03-23T19:24:50"/>

                                                  </xs:restriction>

                                        </xs:simpleType>

                              </xs:attribute>

                    </xs:complexType>

          </xs:element>

          <xs:element name="xml">

                    <xs:complexType>

                              <xs:sequence>

                                        <xs:element name="Schema">

                                                  <xs:complexType>

                                                            <xs:sequence>

                                                                      <xs:element name="ElementType">

                                                                                <xs:complexType>

                                                                                          <xs:sequence>

                                                                                                    <xs:element ref="AttributeType" maxOccurs="unbounded"/>

                                                                                                    <xs:element name="extends">

                                                                                                              <xs:complexType>

                                                                                                                        <xs:attribute name="type" use="required">

                                                                                                                                  <xs:simpleType>

                                                                                                                                            <xs:restriction base="xs:QName">

                                                                                                                                                      <xs:enumeration value="rs:rowbase"/>

                                                                                                                                            </xs:restriction>

                                                                                                                                  </xs:simpleType>

                                                                                                                        </xs:attribute>

                                                                                                              </xs:complexType>

                                                                                                    </xs:element>

                                                                                          </xs:sequence>

                                                                                          <xs:attribute name="name" use="required">

                                                                                                    <xs:simpleType>

                                                                                                              <xs:restriction base="xs:string">

                                                                                                                        <xs:enumeration value="row"/>

                                                                                                              </xs:restriction>

                                                                                                    </xs:simpleType>

                                                                                          </xs:attribute>

                                                                                          <xs:attribute name="content" use="required">

                                                                                                    <xs:simpleType>

                                                                                                              <xs:restriction base="xs:string">

                                                                                                                        <xs:enumeration value="eltOnly"/>

                                                                                                              </xs:restriction>

                                                                                                    </xs:simpleType>

                                                                                          </xs:attribute>

                                                                                          <xs:attribute name="updatable" use="required">

                                                                                                    <xs:simpleType>

                                                                                                              <xs:restriction base="xs:boolean">

                                                                                                              </xs:restriction>

                                                                                                    </xs:simpleType>

                                                                                          </xs:attribute>

                                                                                </xs:complexType>

                                                                      </xs:element>

                                                            </xs:sequence>

                                                            <xs:attribute name="id" use="required">

                                                                      <xs:simpleType>

                                                                                <xs:restriction base="xs:string">

                                                                                          <xs:enumeration value="RowsetSchema"/>

                                                                                </xs:restriction>

                                                                      </xs:simpleType>

                                                            </xs:attribute>

                                                  </xs:complexType>

                                        </xs:element>

                                        <xs:element name="data">

                                                  <xs:complexType>

                                                            <xs:sequence>

                                                                      <xs:element ref="row" maxOccurs="unbounded"/>

                                                            </xs:sequence>

                                                  </xs:complexType>

                                        </xs:element>

                              </xs:sequence>

                    </xs:complexType>

          </xs:element>

</xs:schema>

* I have needed to eliminate <xs:enumeration value="true"/> and you pay attention if you needed <xs:restriction base="xs:boolean">  or it is other type.

4. I imported this xsd without problems in XI/PI.

5. If you create an dummy xsd to the sender, you could apply the above XSL in operation mapping and put this xsd in the receiver, later you create the server Proxy with this last schema.

Regards and good luck.