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

Re: Multiple relationships

Subject: Re: Multiple relationships
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 6 May 2002 15:05:07 +0100
how to have multiple relationships
Hi Craig,

> I need to select the relationship type that fits some rules and
> display only that relationship and the party information that goes
> with it. Any suggestions as to how to code the XSL to do this?

You haven't given many details, so it's a bit difficult to answer your
question.

What do you mean by "the relationship type that fits some rules"? Do
you mean that you have the value for the RelationRoleCode for the
Relation object? Or some other combination of information? Without
knowing the details, I'd suggest that you use a key to quickly get to
the Relation based on whatever the rules are. So for example if you
need to get to it based on its RelationRoleCode, then use:

<xsl:key name="relations" match="Relation" use="RelationRoleCode" />

Then you can get all the Relation objects that have the
RelationRoleCode 'Owner', for example, using:

  key('relations', 'Owner')

If, say, you had that value as a $relationRole stylesheet parameter:

<xsl:param name="relationRole" />

you could apply templates to the relevant Relations using:

<xsl:template match="/">
  <xsl:apply-templates select="key('relations', $relationRole)" />
</xsl:template>

Then you need to have a template that prints out information about the
relation. I guess that the "RelatedObjectID" attribute on a Relation
is a reference to the id of a Party element elsewhere in the document?
If so, then you should have another key for Party elements:

<xsl:key name="parties" match="Party" use="@id" />

So given that you're processing a Relation you can get hold of the
Party element representing the related object using:

  key('parties', @RelatedObjectID)

So you might have a couple of templates -- one for Relation elements,
and one for Party elements -- that look like:
  
<xsl:template match="Relation">
  <h3><xsl:value-of select="RelationRoleCode" /></h3>
  <dl>
    <dt><xsl:value-of select="RelatedObjectType" /></dt>
    <dd>
      <xsl:apply-templates select="key('parties', @RelatedObjectID)"/>
    </dd>
  </dl>
</xsl:template>

<xsl:template match="Party">
  <xsl:value-of select="FullName" />
  <address>
    <xsl:for-each select="Line1 | Line2 | Line3">
      <xsl:value-of select="." />,<br />
    </xsl:for-each>
    <xsl:value-of select="City" />,<br />
    <xsl:value-of select="AddressState" />
    <xsl:text> </xsl:text>
    <xsl:value-of select="Zip" />
  </address>
</xsl:template>

You probably want to do the same kind of thing with the
OriginatingObjectID attribute, but it doesn't seem to be holding the
id of a Party (from the sample that you sent), so perhaps you need
something different there. It's hard to tell.

I hope that's given you some ideas. Do come back with some more
details (a sample of the output you want, for example, and the XSLT
that you've tried) if you run into problems or if my guesses above are
way off.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.