XML output generation

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

eostic wrote:How many posts do I have compared to some of you true heros on this forum? :)
Don't matter - you are the DataStage XML God-Like Guru. And we all know you're holding back so as to not embarass us all. :wink:

Thanks for popping in and contributing.
Last edited by chulett on Wed Apr 18, 2007 11:50 am, edited 2 times in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Well...thanks for the high praise. I'll debate you over a beer sometime whether I deserve it. ;)
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...and btw... definitely not a "god" of XML. Very familiar with how it works with DS perhaps, but not of XML in general (I just know the right people to speak with when it gets ugly and deep into the weeds). :)

Ernie
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There ya go - edited for clarity. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

btw...said document was written by one of our engineers who helped develop the original XMLPack and is a great read.

Ernie
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

I am still waiting for xsd guys. Once I have it, I will come back to this and will let you know. But I dont think XML meta data importer will accept the DTD file to import. Its asking for the xml file or xsd file.
When I use the dtd file, it is throwing a format error.
The File specified was not recognized as a valid XML or XML Schema document
.
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No one is suggesting you can import from the DTD, we've already established you can't. Ernie suggested using something like XML Spy to convert your DTD to an xsd - with the caveats he noted.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Right, and I think it's fairly certain that an XSD has nothing to do with it. These appear to be three mutually exclusive groupings --- and will require, as you've found, three separate XML Stages. One job is easier than three, but in the end, the methodology is the same.
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

Hi guys does any body know how to get rid of the below text while generating xml using xml stage? Please let me know.

<!--
- Generated by Ascential Software Corporation, DataStage - XMLOutput stage -
- Mon Apr 23 17:00:47 2007
-->
Venkat Velagapudi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Turn off the option that includes it - the Comment option under Document Settings from what I remember.
-craig

"You can never have too many knives" -- Logan Nine Fingers
velagapudi_k
Premium Member
Premium Member
Posts: 142
Joined: Mon Jun 27, 2005 5:31 pm
Location: Atlanta GA

Post by velagapudi_k »

Hi all, right now I am able to generate an xml file below with 4 different DS jobs appending to the same file.

<!-- Area -->
<entry org_cd="00010" org_level_cd="AREA" name="USSTO" locationname="COMPANY1">
<orgrel org_cd="COMPANY1" org_level_cd="AREA" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Division -->
<entry org_cd="USSTD" org_level_cd="DIV" name="US Stores Division" locationname="USSTO">
<orgrel org_cd="USSTO" org_level_cd="AREA" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Regions -->
<entry org_cd="00010" org_level_cd="REG" name="REGION 10 SOUTHEAST" locationname="USSTD">
<orgrel org_cd="USSTD" org_level_cd="DIV" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<entry org_cd="00011" org_level_cd="REG" name="REGION 11 NORTHEAST" locationname="USSTD">
<orgrel org_cd="USSTD" org_level_cd="DIV" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<entry org_cd="00012" org_level_cd="REG" name="REGION 12 NON TRAD" locationname="USSTD">
<orgrel org_cd="USSTD" org_level_cd="DIV" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Districts -->
<entry org_cd="00001" org_level_cd="DIST" name="DISTRICT 1 SO FL DAD" locationname="REGION 25 SOUTH">
<orgrel org_cd="00025" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<entry org_cd="00002" org_level_cd="DIST" name="DISTRICT 2 CL ATLAN" locationname="REGION 10 SOUTHEAST">
<orgrel org_cd="00010" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<entry org_cd="00003" org_level_cd="DIST" name="DISTRICT 3 SO ATLAN" locationname="REGION 10 SOUTHEAST">
<orgrel org_cd="00010" org_level_cd="REG" eff_date="01/01/1900"/>
<status code="Active" eff_date="01/01/1900"/>
</entry>
<!-- Stores -->
<entry org_cd="00001" org_level_cd="STORE" name="00001" locationname="LAUDERDALE LAKES,FL" address1="3301 N STATE RD" address2="# 7 LAKES MALL" city="LAUDERDALE LAKES" state="FL" zip="33319" phone1="9547336100" timezone_cd="EST">
<orgrel org_cd="00010" org_level_cd="DIST" eff_date="12/29/1986"/>
<status code="Active" eff_date="12/29/1986"/>
</entry>
<entry org_cd="00003" org_level_cd="STORE" name="00003" locationname="MIAMI,FL" address1="8665 BIRD RD" address2="" city="MIAMI" state="FL" zip="33155" phone1="3052231912" timezone_cd="EST">
<orgrel org_cd="00001" org_level_cd="DIST" eff_date="11/15/1986"/>
<status code="Active" eff_date="11/15/1986"/>
</entry>
<entry org_cd="00004" org_level_cd="STORE" name="00004" locationname="BOCA RATON,FL" address1="123 NW 13TH ST" address2="" city="BOCA RATON" state="FL" zip="33432" phone1="5613954001" timezone_cd="EST">
<orgrel org_cd="00177" org_level_cd="DIST" eff_date="09/21/1987"/>
<status code="Active" eff_date="09/21/1987"/>
</entry>
<entry org_cd="00007" org_level_cd="STORE" name="00007" locationname="HIALEAH,FL" address1="5301 W 20TH AVE" address2="" city="HIALEAH" state="FL" zip="33012" phone1="3053628155" timezone_cd="EST">
<orgrel org_cd="00033" org_level_cd="DIST" eff_date="08/24/1987"/>
<status code="Active" eff_date="08/24/1987"/>
</entry>
<entry org_cd="00009" org_level_cd="STORE" name="00009" locationname="NORCROSS,GA" address1="5495 JIMMY CARTER BLVD" address2="" city="NORCROSS" state="GA" zip="30093" phone1="7704466646" timezone_cd="EST">
<orgrel org_cd="00002" org_level_cd="DIST" eff_date="12/21/1987"/>
<status code="Active" eff_date="12/21/1987"/>
</entry>

Is there a way to add a top level element to the above xml with the help of a datastage job like

<Orgapiload>
above xml here
</Orgapiload>

When I am opening the above xml, I am getting the below error.

Only one top level element is allowed in an XML document. Error processing resource


Any feedback is appreciated.
Venkat Velagapudi
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Absolutely. Just pass it thru "one more" XMLOutput Stage (which is what you'd do if it were all in a single job. You can't just "paste" the xml snippets together without wrapping them in a higher level element(s).

So... have an XMLOutput stage with an input link and an output link.... one column on each.

On the input side, feed it your XML.... and have (minimally) a Description property for that column that is just "/Orgapiload " (without the quotes).

On the output side, have a column called myNewXML....give it varchar and a long length mostly for doc purposes, with a single "/" in the Description property (also without quotes).

Should work like a charm.

Ernie
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

btw.... In looking at this answer, I forgot to mention that you need to give it a "DataElement" of XML, to ensure that "your" XML doesn't get "escaped".

In other words, when you pump your previously created xml string into the XMLOutput Stage, you don't want <myElement> to come out on the other side as &gt myElement &lt..... the XML DataElement tells the stage to "leave the string alone".

Ernie
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... for some silly reason I was under the opposite impression. :?

I thought 'XML' meant the output needed to be 'XML Friendly' and thus would do those conversions. But then, the last time I tried to find out where all those data elements were documented, I failed miserably. :cry:
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

One way to think of it is this --- by default, it should _always_ escape any < or > properly....it's possible for such characters to occur randomly in any sort of string. The XML (don't escape) is the rare exception when you are doing your own custom technique. It is confusing though, I agree.

Ernie
Post Reply