xsl-list
[Top] [All Lists]

RE: How do I locate the parent of this node?

2002-10-17 00:33:58
Thanks for the suggestion, Joerg. I'm not clear about the syntax, though.
Should it look like this?...

parent::$currentNode

or something else? I guess my basic difficulty is that I'm not sure, having
passed the parameter $currentNode into the template, how to get $currentNode
as the context node in order to find its parent. Or am I missing something
obvious here?


Steve Lake



-----Original Message-----
From: Joerg Heinicke [mailto:joerg(_dot_)heinicke(_at_)gmx(_dot_)de]
Sent: 16 October 2002 19:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] How do I locate the parent of this node?


simply use ".." or "parent::XMLDataItem".

Regards,

Joerg

steve(_dot_)l(_dot_)lake(_at_)bt(_dot_)com wrote:
Help, please! 

For the XML data structure below I'm trying to use a recursive template to
piece together the 'path' of each XMLDataItem element. Thus for the
XMLDataItem whose @Name is 'POIssuedDate' I want the template to return
the
path as '/bat:Batch/PurchaseOrder/OrderHeader'

To do this I need an XPath statement inside the template to locate the
parent node of the current node. I've been using...

//XMLDataItem[child::XMLDataItem/@Name=$currentNode/@Name]

(where $currentNode is the parameter passed into the template). However,
it's not finding that parent node - actually, in this instance it's not
finding anything. Any suggestions?


<XMLData>

  <XMLDataItem
    DataItemType="XMLElement"
    Name="bat:Batch">

    <XMLDataItem
      DataItemType="Attribute"
      Name="BatchID"
      Description="Unique identifier for the batch file"
      Source="Customer"
      MandatoryOptional="M"
      Format="Aplhanumeric(20)"
      ValidationNotes="Must only include characters valid for use in
Windows
file names (reserved characters, such as : are invalid)">
    </XMLDataItem>

    <XMLDataItem
      DataItemType="Attribute"
      Name="NoOfEntries"
      Description="The number of purchase orders in the batch file"
      Source="Customer"
      MandatoryOptional="M"
      Format="Numeric"
      ValidationNotes="This must match the number of orders within the
batch
file">
    </XMLDataItem>

    <XMLDataItem>
      DataItemType="XMLElement"
      Name="PurchaseOrder"

      <XMLDataItem>
        DataItemType="XMLElement"
        Name="OrderHeader"

        <XMLDataItem
          DataItemType="XMLElement"
          Name="POIssuedDate"
          Description="Date/time of creation of the order by the service
provider"
          Source="Customer"
          MandatoryOptional="M"
          Format="ccyymmddThh:mm:ss"
          ValidationNotes="Must be a valid date/time">
        </XMLDataItem>

        <XMLDataItem
          DataItemType="XMLElement"
          Name="RequestedDeliveryDate"
          Description="Date/time by which the order is required by the
service provider"
          Source="Customer"
          MandatoryOptional="M"
          Format="ccyymmddThh:mm:ss"
          ValidationNotes="Must be a valid date/time, recommended to be at
least 7 days from submission; cannot be date in the past. This date/time
is
repeated later in the order and both occurrences must be the same.">
        </XMLDataItem>

        <XMLDataItem>
          DataItemType="XMLElement"
          Name="OrderReference"

          <XMLDataItem>
            DataItemType="XMLElement"
            Name="AccountCode"

            <XMLDataItem>
              DataItemType="XMLElement"
              Name="Reference"

              <XMLDataItem
                DataItemType="XMLElement"
                Name="RefNum"
                Description="Billing account reference"
                Source="Customer"
                MandatoryOptional="M"
                Format="Alphanumeric(20)"
                ValidationNotes="This must match the value supplied on
registration">
              </XMLDataItem>
            </XMLDataItem>
          </XMLDataItem>

          <XMLDataItem>
            DataItemType="XMLElement"
            Name="BuyerRefNum"

            <XMLDataItem>
              DataItemType="XMLElement"
              Name="Reference"

              <XMLDataItem
                DataItemType="XMLElement"
                Name="RefNum"
                Description="The unique identifier number for the end user
order"
                Source="Customer"
                CustomerMandatoryOptional="M"
                Format="Alphanumeric(20)"
                ValidationNotes="">
              </XMLDataItem>

            </XMLDataItem>

          </XMLDataItem>

        </XMLDataItem>

      </XMLDataItem>

    </XMLDataItem>

  </XMLDataItem>

</XMLData>
Steve Lake

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list