Page 1 of 1

\b{Irregular XML from XMLOutput stage}

Posted: Thu Jun 22, 2006 12:19 am
by pavankvk
Hi

this is my sample schema.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="IDMIdentTran">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="BusNameGrp"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="BusNameGrp">
<xs:complexType>
<xs:sequence>
<xs:element ref="BusName"/>
<xs:element ref="BusNameState"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="BusName" type="xs:string"/>
<xs:element name="BusNameState" type="xs:NCName"/>
</xs:schema>

I want to populate 3 rows from a table to a xml file with 2 columns in each row.

the 2 columns are BusName and BusNameState.

I expect the output to be

<IDMIdentTran>
<BusNameGrp>
<BusName>
DUNKIN DONUTS
</BusName>
<BusNameState>
CT
</BusNameState>
</BusNameGrp>
<BusNameGrp>
<BusName>
DUNKIN DONUTS
</BusName>
<BusNameState>
NJ
</BusNameState>
</BusNameGrp>
<BusNameGrp>
<BusName>
DUNKIN DONUTS
</BusName>
<BusNameState>
CA
</BusNameState>
</BusNameGrp>
</IDMIdentTran>


But this is what i get from the XMLOutput
------------------------------------------

<IDMIdentTran>
<BusNameGrp>
<BusNameState>
CT
</BusNameState>
<BusNameState>
CT
</BusNameState>
<BusNameState>
CT
</BusNameState>
</BusNameGrp>
</IDMIdentTran>
Name>
DUNKIN DONUTS
</BusName>
<BusName>
BEE LINE AUTO & TIRE CENTER INC
</BusName>
</BusNameGrp>
</IDMIdentTran>

I dont know why the BusName element is getting screwed up. i see a "Name>" tag in the out put and dont understand the reason it is happening. i highlighted the wrong formatted area.

Any insights are appreciated.[/b]

Posted: Thu Jun 22, 2006 12:31 am
by ray.wurlod
Just the obvious one: your schema has two element tags following the close of your complex type. What is intended by these?

Here are the last five lines of your schema:
</xs:complexType>
</xs:element>
<xs:element name="BusName" type="xs:string"/>
<xs:element name="BusNameState" type="xs:NCName"/>
</xs:schema>


In general, the opening and closing tags in your schema don't seem to match up very well.

Posted: Thu Jun 22, 2006 12:36 am
by pavankvk
Ray

those are the element definitions that need to be defined. they appear withing the businessgrp tag which repeats n times.

Posted: Thu Jun 22, 2006 12:46 am
by pavankvk
bcoz those are the only 2 elements that can have value, they need to be separately defined.i validated the xml and the schema in a xml editor.so they should be fine.i dont understand the problem with xmloutput. i tried for one element repeating under busnmgrp tag and it works properly.

Posted: Thu Jun 22, 2006 6:10 am
by chulett
Suggest you get yourself over to ADN (sign up if you haven't) and download the XML Pack Best Practices document from there. If is extremely helpful in general for dealing with XML in DataStage and includes a specific section on handling multiple repeating elements.