XML InputStage - Getting all Element Values from XML File

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
turash
Premium Member
Premium Member
Posts: 51
Joined: Fri Apr 06, 2007 10:09 am
Location: Edison, NJ

XML InputStage - Getting all Element Values from XML File

Post by turash »

I have to extract values from all MappingElement ElementId in following XML File.

Code: Select all

<Response>
	<Header/>
	<XmlTransaction>
		<TransName>MAP</TransName>
		<Completiontext>Successful</Completiontext>
		<CompletionCode>1</CompletionCode>
		<ReferenceMapping>
			<AppSource>XX</AppSource>
			<TargetSystemId>YY</TargetSystemId>
			<EffectiveDt>2008-01-30</EffectiveDt>
			<Attributes/>
			<Codes>
					<MappingElement ElementId="P1">
					<SourceGroup>
						<Off>777</Off>
						<PSS>03456</PSS>
					</SourceGroup>
					<TargetGroup>
						<HF>55403456</HF>
					</TargetGroup>
				</MappingElement>	
				<MappingElement ElementId="P2">
					<SourceGroup>
						<Country>US</Country>
					</SourceGroup>
					<TargetGroup>
						<Country>001</Country>
					</TargetGroup>
				</MappingElement>	
			</Codes>
		</ReferenceMapping>	
	</XmlTransaction>
</Response>

Xpath
Image

I am not able to extract Second element
MappingElement ElementId="P2"

Thanks in advance!!
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Did you get anything at all? This should yeild an error because there is no key selected for your repetitition element. Tell us what happens when, for example, you make Country under target group your repetition element, and then be sure that "repetition element required" is unchecked in the properties....

You should get two rows.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
turash
Premium Member
Premium Member
Posts: 51
Joined: Fri Apr 06, 2007 10:09 am
Location: Edison, NJ

Post by turash »

eostic wrote:Did you get anything at all? This should yeild an error because there is no key selected for your repetitition element. Tell us what happens when, for example, you make Country under target group your repetition element, and then be sure that "repetition element required" is unchecked in the properties....

You should get two rows.

Ernie
Part of the problem is when I try to import xml structure Country under target group does not appear for selection.

If i make element id as key and repetition element
I get two rows but not able to extract country values in source and target group
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Since you are already asking for the details from each of the two groups, just add the columns you want by hand:

SourceCountry ...... /...../...../..... etc...../SourceGroup/Country/text()


and

TargetCountry..... /..../..../....etc ..../TargetGroup/Country/text()

It "looks" like these are singly occurring, so make either country your repeating element and you should be fine, but be certain to uncheck "repeating element required" or else you will lose Mappings if the Country element is not present.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
turash
Premium Member
Premium Member
Posts: 51
Joined: Fri Apr 06, 2007 10:09 am
Location: Edison, NJ

Post by turash »

Thanks a lot Ernie
eostic wrote:Since you are already asking for the details from each of the two groups, just add the columns you want by hand:

SourceCountry ...... /...../...../..... etc...../SourceGroup/Country/text()


and

TargetCountry..... /..../..../....etc ..../TargetGroup/Country/text()

It "looks" like these are singly occurring, so make either country your repeating element and you should be fine, but be certain to uncheck "repeating element required" or else you will lose Mappings if the Country element is not present.

Ernie
Post Reply