This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]