Page 1 of 1

MQ

Posted: Wed Sep 24, 2008 4:36 am
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 ?

Posted: Wed Sep 24, 2008 5:32 am
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

Posted: Wed Sep 24, 2008 7:43 am
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

Posted: Wed Sep 24, 2008 8:52 am
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]

Posted: Wed Sep 24, 2008 1:43 pm
by eostic
Spaces in XML are "noise".

Posted: Wed Sep 24, 2008 4:37 pm
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

Posted: Wed Sep 24, 2008 8:09 pm
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 ?

Posted: Wed Sep 24, 2008 9:10 pm
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

Posted: Thu Sep 25, 2008 12:21 am
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/) ?

Posted: Thu Sep 25, 2008 6:01 am
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

Posted: Thu Sep 25, 2008 8:04 pm
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 ""

Posted: Fri Sep 26, 2008 11:24 am
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

Posted: Sun Sep 28, 2008 7:01 pm
by cosec
Thanks Ernie......