Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - RE: [xsl] Joining xml documents on the fly >Thread Next - RE: [xsl] Joining xml documents on the fly Re: [xsl] Joining xml documents on the flyTo: xsl-list@-----.------------.--- Date: 6/4/2009 3:11:00 PM Ah! Yes. it is there for a reason. I tried what you did thinking "Oh,
this is so simple." But it is not that way, because I need to include
*all* of the staff, even those that have not yet been added to projects.
So there is Jason Altman, he is not in the project_staff_roles document,
but I still need to include him in the non-project staff.
Sorry I was not clearer about pointing that out. I was a little fuzzy in
the head yesterday.
Thanks,
Joelle
Michael Kay wrote:
> One of the tricks of the trade in doing maths and physics questions at
> school was that they never provided any information you didn't need. Real
> life isn't like that, and as far as I can see the first file is a red
> herring, it's not needed and it's only there to confuse us.
>
> If $psr is the <project_staff_roles> element and $pid is the project id,
> then the project staff are:
>
> <people>
> <xsl:copy-of select=$psr/project_staff_role[@project_id=$pid]/staff"/>
> </people>
>
> and the non-project staff are:
>
> <people>
> <xsl:copy-of select=$psr/project_staff_role[@project_id!=$pid]/staff"/>
> </people>
>
> Or have I overlooked something?
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay
>
>
>
>
>> -----Original Message-----
>> From: Joelle Tegwen [mailto:tegwe002@u...]
>> Sent: 03 June 2009 22:33
>> To: xsl-list@l...
>> Subject: [xsl] Joining xml documents on the fly
>>
>> Ok, I'm in totally over my head here. I'm hoping someone can
>> help me out.
>>
>> I've got 2 external (reference) documents I'm including into
>> my stylesheet.
>>
>> One is a list of staff. It looks like this (edited for brevity):
>>
>> <people>
>> <staff staff_id="123456789" alpha_key="A" sort_key="AberyBrian">
>> <display_name>Brian H Abery</display_name>
>> </staff>
>> <staff staff_id="987654321" alpha_key="A" sort_key="AlbusDeb">
>> <display_name>Deb Albus</display_name>
>> </staff>
>> <staff staff_id="456321789" alpha_key="A" sort_key="AltmanJason">
>> <display_name>Jason R Altman</display_name>
>> </staff>
>> </people>
>>
>> And the other is the three way join between staff, projects
>> and roles <project_staff_roles>
>> <project_staff_role project_id="1" staff_id="123456789"
>> role_id="staff">
>> <staff staff_id="123456789" alpha_key="A"
>> sort_key="AberyBrian">
>> <display_name>Brian H Abery</display_name>
>> </staff>
>> </project_staff_role>
>> <project_staff_role project_id="1" staff_id="123456789"
>> role_id="director">
>> <staff staff_id="123456789" alpha_key="A"
>> sort_key="AberyBrian">
>> <display_name>Brian H Abery</display_name>
>> </staff>
>> </project_staff_role>
>> <project_staff_role project_id="2" staff_id="987654321"
>> role_id="staff">
>> <staff staff_id="987654321" alpha_key="A" sort_key="AlbusDeb">
>> <display_name>Deb Albus</display_name>
>> </staff>
>> </project_staff_role>
>> </project_staff_roles>
>>
>> I want to break this into two groups based on the current project_id.
>> So if I'm viewing project_id=1
>> I want two groups of people
>>
>> Project Staff:
>> <people>
>> <staff staff_id="123456789" alpha_key="A" sort_key="AberyBrian">
>> <display_name>Brian H Abery</display_name>
>> </staff>
>> </people>
>>
>> Non-Project-Staff
>> <people>
>> <staff staff_id="987654321" alpha_key="A" sort_key="AlbusDeb">
>> <display_name>Deb Albus</display_name>
>> </staff>
>> <staff staff_id="456321789" alpha_key="A" sort_key="AltmanJason">
>> <display_name>Jason R Altman</display_name>
>> </staff>
>> </people>
>>
>> I've got the following variables in my document:
>> <xsl:variable name="staff" select="document($ref_staff)/people"/>
>> <xsl:variable name="staff_roles"
>> select="document($ref_project_staff_role)/project_staff_roles/
>> project_staff_role[@role_id='staff']"/>
>> <xsl:variable name="project_staff"
>> select="$staff_roles[@project_id=$[project_id]/staff"/>
>> <xsl:variable name="non_project_staff" select="?????"/>
>>
>> How do I even go about thinking about this? I've tried
>> googling it but I have no idea what to search on. I've tried
>> various iterations of keys, etc but I just can't get it.
>>
>> The final xslt that gives the desired output is:
>> <xsl:if test="count($project_staff) > 0">
>> <fieldset class="span-18 last col-wrap">
>> <legend class="quiet">
>> <xsl:value-of
>> select="ancestor::project/associates/associate/title"/>
>> People</legend>
>> <xsl:call-template name="layout_3column">
>> <xsl:with-param name="objects"
>> select="$project_staff"/>
>> </xsl:call-template>
>> </fieldset>
>> </xsl:if>
>>
>> <xsl:if test="count($non_project_staff) > 0">
>> <fieldset class="span-18 last col-wrap">
>> <legend class="quiet">All Other People</legend>
>> <div id="tabs">
>> <ul>
>> <xsl:for-each
>>
>> select="$staff/staff/@alpha_key[generate-id()=generate-id(key('alpha',
>> .))]">
>> <xsl:if
>> test="count($non_project_staff[@alpha_key = current()]) > 0">
>> <xsl:call-template name="tab_link">
>> <xsl:with-param
>> name="alpha_string"
>> select="."/>
>> </xsl:call-template>
>> </xsl:if>
>> </xsl:for-each>
>> </ul>
>> <xsl:for-each
>>
>> select="$staff/staff/@alpha_key[generate-id()=generate-id(key('alpha',
>> .))]">
>> <xsl:if
>> test="count($non_project_staff[@alpha_key = current()]) > 0">
>> <xsl:call-template name="tab_data">
>> <xsl:with-param name="alpha_string"
>> select="."/>
>> <xsl:with-param name="objects"
>>
>> select="$non_project_staff[@alpha_key = current()]"/>
>> </xsl:call-template>
>> </xsl:if>
>> </xsl:for-each>
>> </div>
>>
>> </fieldset>
>> </xsl:if>
>>
>>
>> I hope this is clear. Any help would be much appreciated.
>>
>> Thanks in advance.
>> Joelle
>>
>>
>>
>>
>> --~------------------------------------------------------------------
>> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
>> or e-mail: <mailto:xsl-list-unsubscribe@l...>
>> --~--
>>
>>
>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@l...>
> --~--
>
>
>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
