Reading value of STX attribute

Posted on 2006-03-29
Last Modified: 2013-11-19
Hey experts,

 I have the following xml file:

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

 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:group name="Ediroot">
    <stx:template match="interchange">
     <stx:process-attributes group = "dateAttr" />
     <stx:process-children group="Interchange"/>

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]">

any help on what should I do to read the value in the Date attribute??
Question by:mte01
    LVL 60

    Accepted Solution

    <stx:assign name="pricatDate" select="interchange/@Date">
    LVL 3

    Author Comment

    Yes..that worked!!..(with some modifications since I put it at a different node)
    LVL 3

    Author Comment

    Thanks for your help!
    LVL 60

    Expert Comment

    by:Geert Bormans
    you are welcome

    note the following
    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

    LVL 3

    Author Comment

    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!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now