Thread View: comp.text.xml
2 messages
2 total messages
Started by Mike Bowling
Tue, 13 Feb 2001 19:06
Expert XML/XSL?
Author: Mike Bowling
Date: Tue, 13 Feb 2001 19:06
Date: Tue, 13 Feb 2001 19:06
53 lines
3847 bytes
3847 bytes
Are you the expert that can help me with an XML/XSL prob? Here it is:
I have element(s) "Party" in my xml doc
<Party PartyType="A" ID="003439" UDF1="Schultz"
Name="Boise Property Appraisers" UDF3="B328">
<ContactDetail ContactPointRole="WORK"
ContactPointType="PHONE" Value="(301) 557-2366"/>
<ContactDetail ContactPointRole="WORK"
ContactPointType="EMAIL" Value="alex@boise.net"/>
<PersonName LastName="Appraiser" FirstName="Alex
"/>
<Address StreetAddress1="45 East Wilkes Street,
Suite 14" City="Boise" State="ID" County="Boise" Zip="78620"/>
</Party>
<Party PartyType="B" ID="003438" UDF1="Schultz"
Name="ABC Mortgage Co" UDF3="B328">
<ContactDetail ContactPointRole="WORK"
ContactPointType="PHONE" Value="(302) 478-8617"/>
<ContactDetail ContactPointRole="WORK"
ContactPointType="EMAIL" Value="jjones@aol.com"/>
<PersonName LastName="Smith" FirstName="John "/>
<Address StreetAddress1="330 Pike St"
City="Wilmington" State="DE" County="Unknown" Zip="19802"/>
</Party>
I needed to show values only from the second element and did it this
way:
<xsl:if test="@PartyType[.!value()='B']">
and then listed the variables I wanted, ie...
<xsl:value-of select="PersonName/@FirstName"/>
...and so on, and it works fine
HOWEVER, now I need to show both ContactDetail/@Value values (inside
PartyType B), the phone and the email addy. My problem is it shows only
the first, and if I try to make it show both, it only lists the phone
number twice.
Aaaaargh! I've been trying to solve this for two days, what am I
missing?. HELP!
There's a beer (or your choice of beverage, etc.) in it for whoever can
help...
Thanks,
MikeMonster
mikebowling@hotmail.com
Re: Expert XML/XSL?
Author: Carl Ranson
Date: Tue, 13 Feb 2001 20:43
Date: Tue, 13 Feb 2001 20:43
89 lines
4953 bytes
4953 bytes
Surely its just something along the lines of:
<xsl:template match="Party">
<xsl:if test="@PartyType[.!value()='B']">
<xsl:foreach select="ContactDetail">
<xsl:value-of ....(your stuff here) />
</xsl:foreach>
</xsl:if>
</xsl:template>
alternatively you could do it with another template.
<xsl:template match="ContactDetail">
(your stuff here)
</xsl:template>
<xsl:template match="Party">
<xsl:if test="@PartyType[.!value()='B']">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
The fact that you said you just get the details twice leads me to belive
you've simply put the value-of in twice. The problem is that the current
node (ie the ContactDetail you're on) hasn't changed. The foreach or apply
templates causes the thing to evaluate for the different nodes.
Hope all this helps, email me if you still cant get it going
(the_nutcase@hotmail.com).
Cheers,
Section8
"Mike Bowling" <mikebowling@hotmail.com> wrote in message
news:3A8985A9.17D30658@hotmail.com...
> Are you the expert that can help me with an XML/XSL prob? Here it is:
>
> I have element(s) "Party" in my xml doc
>
> <Party PartyType="A" ID="003439" UDF1="Schultz"
> Name="Boise Property Appraisers" UDF3="B328">
> <ContactDetail ContactPointRole="WORK"
> ContactPointType="PHONE" Value="(301) 557-2366"/>
> <ContactDetail ContactPointRole="WORK"
> ContactPointType="EMAIL" Value="alex@boise.net"/>
> <PersonName LastName="Appraiser" FirstName="Alex
> "/>
> <Address StreetAddress1="45 East Wilkes Street,
> Suite 14" City="Boise" State="ID" County="Boise" Zip="78620"/>
> </Party>
> <Party PartyType="B" ID="003438" UDF1="Schultz"
> Name="ABC Mortgage Co" UDF3="B328">
> <ContactDetail ContactPointRole="WORK"
> ContactPointType="PHONE" Value="(302) 478-8617"/>
> <ContactDetail ContactPointRole="WORK"
> ContactPointType="EMAIL" Value="jjones@aol.com"/>
> <PersonName LastName="Smith" FirstName="John "/>
>
> <Address StreetAddress1="330 Pike St"
> City="Wilmington" State="DE" County="Unknown" Zip="19802"/>
> </Party>
>
>
> I needed to show values only from the second element and did it this
> way:
>
> <xsl:if test="@PartyType[.!value()='B']">
>
> and then listed the variables I wanted, ie...
>
> <xsl:value-of select="PersonName/@FirstName"/>
>
> ...and so on, and it works fine
>
> HOWEVER, now I need to show both ContactDetail/@Value values (inside
> PartyType B), the phone and the email addy. My problem is it shows only
> the first, and if I try to make it show both, it only lists the phone
> number twice.
>
> Aaaaargh! I've been trying to solve this for two days, what am I
> missing?. HELP!
>
> There's a beer (or your choice of beverage, etc.) in it for whoever can
> help...
>
> Thanks,
> MikeMonster
> mikebowling@hotmail.com
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads