Re: [xsl] How do I locate the parent of this node?

Subject: Re: [xsl] How do I locate the parent of this node?
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Wed, 16 Oct 2002 20:44:32 +0200
simply use ".." or "parent::XMLDataItem".

Regards,

Joerg

steve.l.lake@xxxxxx 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


Current Thread