[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

using XML to reference XML; XPointers and keys

Subject: using XML to reference XML; XPointers and keys
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Mon, 15 Nov 1999 11:19:00 -0700
using xml idref
Perhaps someone can help. I have some source data that looks like:

<doc1>
  <MyData id="101">...</MyData>
  <MyData id="102">...</MyData>
  ...
</doc1>

And I reference it in multiple places in another XML tree:

<doc2>
  ...
  <MyDataRef idref="102"/>
  ...
  <MyDataRef idref="102"/>
  ...
  <MyDataRef idref="101"/>
  ...
</doc2>

I process doc2 with an XSLT stylesheet. When I need to access the MyData
that has the same @id as the MyDataRef @idref, I use a key. This is a fine
abstraction since I have something to key on.

But now I also have to use some source data that looks like this, with
nothing consistent to key on:

<doc3>
  <Merchant MerchantID="123">
    <ContactInfo>
      <Name>Joe's Pizza</Name>
      <Address>1111 22nd Ave</Address>
      <City>Cleveburgville</City>
      <State>OH</State>
      <Phone>2165551212</Phone>
    </ContactInfo>
    ...
  </Merchant>
</doc3>

I'd like to be able to reference this data in a similar way. I'd like to be
able to have in doc2 something like:

<MyDataRef elementref="Address"/>

And then use a key to get the appropriate node in doc3. I think this can be
done, but things get tricky when I need to have repeating elements in doc3.
For example, Address can appear in a different context:

<doc3>
  <Merchant MerchantID="123">
     <ContactInfo>
        <Address>1111 22nd Ave</Address>
     </ContactInfo>
     <BillingInfo>
        <Address>2222 11th St</Address>
     </BillingInfo>
  </Merchant>
</doc3>

How can I point to just the Address that's a child of ContactInfo? Defining
<MyDataRef elementref="/doc3/Merchant/ContactInfo/Address"/> is useless
because I can't, without some kind of recursive voodoo that breaks down as
soon as you hit a predicate, use that elementref string to obtain a
node-set.

It seems like XPointer covers this territory, using an element in a custom
namespace to point to particular nodes or locations in a document's data ...
but it would be up to the XSLT engine to implement them, right?

Any other suggestions for a way to abstract the doc3 data?

-Mike


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.