Link to home
Create AccountLog in
Avatar of mte01
mte01Flag for Lebanon

asked on

Reading value of STX attribute

Hey experts,

 I have the following xml file:

<ediroot>
  <interchange Standard="EDIFACT" SyntaxId="UNOA" SyntaxVersion="4" Date="20060109" Time="0824" Control="P0677/0070" Priority="A" AckRequest="1">
        <group>
      <transaction Control="0677/0070/0001" DocType="PRICAT">
        <segment Id="BGM">
          <element Id="BGM01">9</element>
   ....etc
     </group>
  </interchange>
</ediroot>

 I want to retrieve the value in the Date attribute of the interchange tag, I did the following:

<stx:template match="ediroot">
        <stx:element  name = "root">
            <stx:process-children group="Ediroot"/>
            <stx:value-of select="$newline"/>
        </stx:element>
  </stx:template>

<stx:group name="Ediroot">
    <stx:template match="interchange">
     <stx:process-attributes group = "dateAttr" />
     <stx:process-children group="Interchange"/>
    </stx:template>
  </stx:group>

Then I didn't know what should I do inside the dateAtr group to read the value in the Date Attribute; I tried the following, but it obviously didn't work:

<stx:group name="dateAttr">
    <stx:assign name="pricatDate" select="interchange[@Date]">
  </stx:group>

any help on what should I do to read the value in the Date attribute??
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of mte01

ASKER

Yes..that worked!!..(with some modifications since I put it at a different node)
Avatar of mte01

ASKER

Thanks for your help!
you are welcome

note the following
select="interchange[@Date]"
selects the interchange element that has an attribute Date
[] is a predicate, in there you can put restrictions on the node selection before it
if you would like to select an interchange element that has a date attribute with value '2005-11-24'
it would be like this
select="interchange[@Date = '2005-11-24']"

if you are just selecting the attribute, you need a path with a forward slash, like this interchange/@Date

cheers
Avatar of mte01

ASKER

Yes, I already knew how to find the predicate, and I wanted to know how to find the value of the attribute...thanks for your help!