MQ

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

Post Reply
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

MQ

Post by cosec »

I have an input from a MQ Stage going in to an XML Output Stage and then to a Sequential File.

The XML File has a field <ITEM_DESC> </ITEM_DESC>

After execution in the Sequential file this field is represented as <ITEM_DESC/>

is this representation correct ?
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Indeed. It is an empty element. It can be represented by <ITEM_DESC></ITEM_DESC> or just <ITEM_DESC/>. You have a choice of single or open/close tag representation within the Stage. The latter saves you some space in the document. Save more space by making sure that the formatting option is not checked either.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

But it's not an empty element since it has a space in between
<ITEM_DESC> </ITEM_DESC>
So does that mean Datastage still refers to it as an empty string ?
Also I tried changing the options in the property file and not able to switch to the open/close tag. Any other alternative ?
Thanks for your response.
eostic wrote:Indeed. It is an empty element. It can be represented by <ITEM_DESC></ITEM_DESC> or just <ITEM_DESC/>. You have a choice of single or open/close tag representation within the Stage. The latter saves you some space in the document. Save more space by making sure that the formatting option is not checked either.

Ernie
csri
Participant
Posts: 99
Joined: Wed Jul 11, 2007 8:02 am

Post by csri »

Also I tried changing the options in the property file and not able to switch to the open/close tag. Any other alternative ?
Property file? I am not sure what property file are you refering too.
Make sure you have checked "Open and close tags" option under Transformation Settings in XMLOutput stage. If you did then it should work.
But it's not an empty element since it has a space in between
<ITEM_DESC> </ITEM_DESC>
Are you sure there is a space between the tags. If possible check one space to multiple spaces and test it. It should work.

Hope it helps.[/code]
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Spaces in XML are "noise".
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Didn't have time earlier to put in further details, but whatever tooling or program you are sending the xml too shouldn't care. You can prove this yourself by taking a simple xml document, put in an empty element with both tags, an empty with only one tag, and an empty with blanks....assuming defaults, they will all show up the same in IE.

<fred1></fred1>
<fred2> </fred2>
<fred3/>

There are various xml settings for preserving spaces, but these can get squirrelly...check carefully with tool, program and parser that is receiving the xml. Ultimately, we can find a way to get DataStage to do what you need it to. Let us know exactly how you need it to look to satisfy that program. Under normal circumstances though, that program shouldn't care.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Thanks for the Response.

I am not able to choose which way to generate the output(ie open/close tag or single tag)..Is this because I am using an XML Input Stage and not the XML Output stage?

The reason for my questions are because when the XML Tag is single and when I convert the XML file to a delimited Sequential File the field we are discussing is represented as "" ( Since there is a space in the original file in the MQ I need it to be represented as " ").

Any advice on what changes I should make ?
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I'm not sure I understand exactly what you are trying to accomplish....if you are reading XML from MQ, you should be using XMLInput Stage, not XMLOutput...... but then you wouldn't be creating the tags --- they are coming from another application. Of course, maybe that's another DS job that writes to MQ? Please outline more of the goal.....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Hi,
Currently my job is designed as follows:

An MQ Stage - > XML Input Stage -> Transformer -> Sequential File.

As I mentioned previously in the XML file that is read by the MQ stage the following representation
<ITEM_DESC> </ITEM_DESC>
becomes
<ITEM_DESC/>
in the sequential file.

As I understand from your earlier response this means the same as the close/open tag, but is it possible to retain the same form as in the source ?

I tried the options in the XML Input Stage properties and couldn't find anything to enable or disable single tag representation for empty elements.

Does that mean by default empty elements are represented as single tag (ITEM_DESC/) ?
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...ok...hmm. This is just a parsing issue. Look at the Description for your ITEM_DESC column. It should end with .../.../ITEM_DESC/text() , where ... are upper level elements in the document structure. Sounds like you may have just .../.../ITEM_DESC/ or similar, which says "return the tag and the value".....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Hello Ernie,

Appreciate your assistance.

The Description Section is as follows :
Column 1 : /PR/PR_HEADER/PR_NO/text()
Column 2 : /PR/PR_HEADER/PR_REQ_NO/text()
Column 3 : /PR/PR_HEADER/PR_APPR_DTTM/text()
Column 4 : /PR

The <ITEM_DESC> </ITEM_DESC> is actually inside the 4th column along with other elements. I did place the text() as u suggested but then it represents the entire column as ""
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

If you are grabbing the "whole element" (with just /PM) then you wouldn't want the /text(). That would only be if ITEM_DESC/text() was what you are using.

Interesting result. I'll have to try it. I'm not surprised though.

If indeed, when you physically look at your source with notepad or other editor, and it has <ITEM_DESC> </ITEM_DESC> deep inside the /PR element, but when you write the /PR element with the syntax below and it becomes </ITEM_DESC>, it must simply be reflecting the fact that the entire XML document is being parsed first, and then deciphered and split up according to your XPath. We know this to be the case, because XMLInput brings the entire document into memory so that the xerces and xalan parser and processor can work on it. It appears that the xslt processor prefers to return empty elements usiing the single element syntax.

As noted above they are equivalent. Whoever is reading your flat file needs to recognize that "<ITEM_DESC> </ITEM_DESC>" and "<ITEM_DESC/>" are the same.

...or, if you are getting "<ITEM_DESC/>" but want "<ITEM_DESC> </ITEM_DESC>" just do it in a transformer.

ERnie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Thanks Ernie......
Post Reply