xsl-list
[Top] [All Lists]

[xsl] Re: xsl-list Digest 23 Jun 2007 05:10:01 -0000 Issue 1176

2007-06-23 08:48:04

hi Michael,

thanks for the reply. for added info though, the
second xml with the <addressFieldn> was such because
it came from an input element whose name is
dynamically set. then the "n" or the number after
addressField is an id that i'll be using to reference
that addressField on my database.  

i'm not sure if i explained it right but to give you a
better idea, i'm gonna need to have a form that
dynamically changes the address fields depending on
the country selected. so total address fields will
really vary on what is set for a particular country.
(some has streets+town+postal code, others have
flat+bldg+territory, etc).  

i'll try both your codes and your suggestion on the
xml design still. i'll see if i can get a work around
to arriving at what you suggested. i'll keep you
posted.

big thanks!

-ycon

------------------------------

Date: Fri, 22 Jun 2007 10:20:56 +0100
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] Concatenation of Element Values
Message-ID: <008c01c7b4ae$a3f0b980$6701a8c0(_at_)turtle>

Sorry, the ../* is wrong, it's looking relative to
ID rather than to
ADDRESS. The right answer depends on exactly where
your <addressField1> etc
elements are.

Michael Kay
http://www.saxonica.com/


<xsl:template match="ADDRESS">
  <xsl:for-each select="ADDRESSFIELD/ID">
    <xsl:value-of
select="../*[name()=concat('addressField', 
current())"/>
    <xsl:if test="position()!=last()">;</xsl:if>
  </xsl:for-each>
</xsl:template>

(I'm assuming here that addressField2, etc, are
siblings of 
ADDRESS, but you didn't make this clear).

Incidentally, coding data into element names like
this feels 
like bad XML design. <addressField id="2"> would
be much 
cleaner than <addressField2>.

Michael Kay
http://www.saxonica.com/




 
____________________________________________________________________________________
Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Re: xsl-list Digest 23 Jun 2007 05:10:01 -0000 Issue 1176, Mariecon Saberon <=