\b{Irregular XML from XMLOutput stage}

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

\b{Irregular XML from XMLOutput stage}

Post 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]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post by pavankvk »

Ray

those are the element definitions that need to be defined. they appear withing the businessgrp tag which repeats n times.
pavankvk
Participant
Posts: 202
Joined: Thu Dec 04, 2003 7:54 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply