0

My input XML looks like below

    <?xml version="1.0" encoding="UTF-8"?>
<Transaction-315 xmlns="urn:oracle:b2b:X12/V4010/315" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" XDataVersion="2.0" Standard="X12" Version="V4010" CreatedDate="2020-08-19T02:10:41" CreatedBy="XEngine_4016" GUID="{B5D92E00-E1E2-11EA-B316-02001707181F}">
    <Segment-N9>
        <Element-128>AB</Element-128>
        <Element-127>AMAZON</Element-127>
    </Segment-N9>
    <Segment-N9>
        <Element-128>BC</Element-128>
        <Element-127>65036834</Element-127>
    </Segment-N9>
    <Segment-N9>
        <Element-128>CD</Element-128>
        <Element-127>AMAZON200746994</Element-127>
    </Segment-N9>
</Transaction-315>

I want to retrieve always the value 65036834 . From the above sample Element-128 values are always constant . Hence , i tried to retrieve the Segment-N9 node Element-128='BC'/text() using local-name() function.

/*[local-name()='Transaction-315']/Segment-N9[Element-128='BC']/*[local-name()='Element-127']/text()  

But output is not giving the excepted value. Could you please help me some one on this.

HKmar
  • 45
  • 6
  • You should never need to use a hack like `*[local-name()='…']`. Assign a prefix to the namespace and use it to select your nodes - see: https://stackoverflow.com/a/34762628/3016153 – michael.hor257k Aug 19 '20 at 11:33

1 Answers1

0

There is namespace in Root element, therefore all child must be call with same namespace or local name

Use this

<xsl:value-of select="*[local-name()='Transaction-315']/*[local-name() = 'Segment-N9'][*[local-name() = 'Element-128']='BC']/*[local-name()='Element-127']/text()"/>

See Transformation at https://xsltfiddle.liberty-development.net/naZYrq6

Rupesh_Kr
  • 3,395
  • 2
  • 17
  • 32