Wouldn't it solve the whole problem if you didn't use <xsl:text> in the first place ? Then all the extra spaces would collapse by themselves, wouldn't they?
Michele
-----Original Message-----
From: Encoded Archival Description List [mailto:[log in to unmask]] On Behalf Of Nathan Tallman
Sent: Wednesday, October 09, 2013 11:08 AM
To: [log in to unmask]
Subject: Re: XSLT Question Regarding Unittitle
Unfortunately, that doesn't work. Matching on text() makes the input a string, so apply-templates doesn't work because there are no nodes to apply templates too, just a string. I'll see if I can rewrite to not match on text().
On Wed, Oct 9, 2013 at 11:00 AM, Joyce Chapman <[log in to unmask]> wrote:
> Maybe just add an xsl:apply-templates inside this template:
> <xsl:template match="text()" mode="unittitle"> after your other stuff
> so all the children are included.
>
>
> On Wed, Oct 9, 2013 at 10:35 AM, Nathan Tallman <[log in to unmask]> wrote:
>>
>> Mark,
>>
>> I've run into a snag. Using mode and the template rule you suggested,
>> child elements of unittitle, other than unitdate, are not being
>> processed. Mostly this is noticeable with title tags, as italics and
>> quotes are missing.
>>
>> Any suggestions?
>>
>> Nathan
>>
>> On Tue, Oct 8, 2013 at 10:55 PM, Mark Carlson
>> <[log in to unmask]>
>> wrote:
>> > Hello
>> >
>> > Alter this line to add a mode attribute
>> >
>> > <xsl:apply-templates select="unittitle/text() |
>> > unittitle/*[not(self::unitdate)]" mode="unittitle"/>
>> >
>> > Then add this template rule:
>> >
>> > <xsl:template match="text()" mode="unittitle">
>> >
>> > <xsl:value-of select="normalize-space(.)"/> </xsl:template>
>> >
>> > Not tested.
>> >
>> > Mark
>> >
>> >
>> > On Tue, 8 Oct 2013, Nathan Tallman wrote:
>> >
>> >> Hi all,
>> >>
>> >> I'm trying to adjust a snippet from a cookbook stylesheet. Here's
>> >> what is is now:
>> >>
>> >> <xsl:choose>
>> >> <!--This code processes the elements when unitdate is a
>> >> child of unittitle.-->
>> >> <xsl:when test="unittitle/unitdate">
>> >> <xsl:apply-templates select="unittitle/text() |
>> >> unittitle/*[not(self::unitdate)]"/>
>> >> <xsl:for-each select="unittitle/unitdate">
>> >> <xsl:text> </xsl:text>
>> >> <xsl:value-of select="normalize-space(.)"/>
>> >> </xsl:for-each>
>> >> </xsl:when>
>> >> <!--This code process the elements when unitdate is not a
>> >> child of untititle-->
>> >> <xsl:otherwise>
>> >> <xsl:value-of select="normalize-space(unittitle)"/>
>> >> <xsl:for-each select="unitdate">
>> >> <xsl:text> </xsl:text>
>> >> <xsl:value-of select="normalize-space(.)"/>
>> >> </xsl:for-each>
>> >> </xsl:otherwise>
>> >> </xsl:choose>
>> >>
>> >> What I'd like to do is to normalize the space of everything in
>> >> unittitle, except unitdate, when unitdate is a child of unittitle.
>> >> Normalizing a plain-old unittitle is easy enough, but I run into
>> >> problems when unittitle contain child elements, other than
>> >> unitdate (<title>, for example). I wish I could just add
>> >> normalize-space() to the apply-templates xpath.
>> >>
>> >> Can anyone make any suggestions? Seems like this would've been
>> >> done before.
>> >>
>> >> Thanks,
>> >> Nathan
>> >>
>> >>
>> >>
>> >>
>> >
>
>
>
>
> --
>
> Joyce Chapman
> Communications and Data Analysis Consultant State Library of North
> Carolina
> 4640 Mail Service Center
> Raleigh, NC 27699-4640
> Phone: 919-807-7421 | Fax: 919-733-8748 [log in to unmask]
|