XSL newbie question: how do I only show the first or second item?

R

Robby

Hello,

How can I show only the first AddressLine (or just the second one) in
FormattedAddress?

I have been trying to do this, but can't get it to work...

What I have now is:

<xsl:template match="FormattedAddress">
<xsl:value-of select="[AddressLine()=1]"/>
</xsl:template>

Any help would be very much appreciated.

Cheers,
Roberto
 
M

Martin Honnen

Robby wrote:

How can I show only the first AddressLine (or just the second one) in
FormattedAddress?

The XPath expression
AddressLine
gives you a node set, to filter that you can add a predicate in square
brackets, if you are looking for an element in that node set with a
particular index then use
AddressLine[index]
The first element in a nodeset has index 1!

That is really basic stuff, take a look at some XPath tutorial, for instance
<http://www.zvon.org/xxl/XPathTutorial/General/examples.html>
 
R

Robby

Robby wrote:

How can I show only the first AddressLine (or just the second one) in
FormattedAddress?

The XPath expression
AddressLine
gives you a node set, to filter that you can add a predicate in square
brackets, if you are looking for an element in that node set with a
particular index then use
AddressLine[index]
The first element in a nodeset has index 1!

That is really basic stuff, take a look at some XPath tutorial, for instance
<http://www.zvon.org/xxl/XPathTutorial/General/examples.html>

Martin,

Thank you for your advice.
I looked up the tutorial, which seems to be very clear, with good
exemples.

I tried to translate it to my situation, and came to this:

<xsl:template match=
"ApplicantDetails/Applicant/ApplicantAddressBook/FormattedNameAddress/Ad
dress/FormattedAddress">
<xsl:value-of select="/AddressLine[1]"/>
</xsl:template>

But unfortunately, this doesn't work...
Tried to play with and without slashes, but no luck.

What went wrong?

Any help would be very much appreciated.

Kind regards,
Robby
 
H

Harrie

Robby said the following on 10/11/2005 14:34 +0200:
I tried to translate it to my situation, and came to this:

<xsl:template match=
"ApplicantDetails/Applicant/ApplicantAddressBook/FormattedNameAddress/Ad
dress/FormattedAddress">
<xsl:value-of select="/AddressLine[1]"/>
</xsl:template>

<xsl:template match="AddressLine[1]">
<xsl:value-of select="." />
</xsl:template>

There's probably a better way (I'm no expert).
 
R

Robby

I tried to translate it to my situation, and came to this:
<xsl:template match=
"ApplicantDetails/Applicant/ApplicantAddressBook/FormattedNameAddress/Ad
dress/FormattedAddress">
<xsl:value-of select="/AddressLine[1]"/>
</xsl:template>

But unfortunately, this doesn't work...

Dear people,

Got it. I was trying to do it too complicated.
And learned that you can't have an xsl:template match inside another...
;-)

What did the trick, was simply:
<xsl:value-of select=
"ApplicantDetails/Applicant/ApplicantAddressBook/FormattedNameAddress/Ad
dress/FormattedAddress/AddressLine[1]" />

Thanks to all for your kind help,
Robby
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top