RE: [xsl] Normalizing space / XPTY0004

Subject: RE: [xsl] Normalizing space / XPTY0004
From: Lief Erickson <lief@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Jul 2013 00:12:19 +0000
That explains it. Thank you.

> -----Original Message-----
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: Monday, July 29, 2013 6:10 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Normalizing space / XPTY0004
>
> When xsl:value-of (in 2.0) selects multiple items, they are output with a
> separator between adjacent items. The separator defaults to a single space.
> You can change the separator for example by writing <xsl:value-of
> select="..." separator=""/> which uses a zero-length string (i.e. no
separator
> at all).
>
> normalize-space() isn't going to help you in the slightest. The reason it
fails is
> that it expects a single string as its first argument, not a sequence of
strings.
>
> You could also write
>
> <xsl:for-each select="Text"><xsl:value-of select="@value"/></xsl:for-each>
>
> Michael Kay
> Saxonica
>
> On 29 Jul 2013, at 23:55, Lief Erickson wrote:
>
> > Hi All--
> >
> > XSLT 2.0
> > Saxon EE 9.5.0.2 (in oXygen 15.0)
> >
> > I have a question about normalizing space -- at least I think that's what
my
> question is about. I am matching the following TextRun/Text values, but the
> output is putting a space either after the end of the line or before the
> beginning (I can't tell which). That makes the word "are" become "ar e" and
> "larger" become "lar ger" and "unchanged" become "unchang ed". Obviously
> this is not my desired result, but the processor is dutifully matching
exactly
> what it finds.
> >
> >      <Paragraph stylename="Body">
> >         <TextRun>
> >            <Text value="If enabled, only the first N-bytes of each ingress
packet
> ar"/>
> >            <Text value="e forwarded to Tool Ports connected to the rule.
> Packets lar"/>
> >            <Text value="ger than the trim length are 'trimmed' to the
size
> specified"/>
> >            <Text value=". Packets smaller than the trim length are
forwarded
> unchang"/>
> >            <Text value="ed."/>
> >         </TextRun>
> >      </Paragraph>
> >
> >
> >    <xsl:template match="Paragraph[@stylename = 'Body']">
> >        <xsl:value-of select="./TextRun/Text/@value"/>
> >    </xsl:template>
> >
> > Output:
> > If enabled, only the first N-bytes of each ingress packet ar e forwarded
to
> Tool Ports connected to the rule. Packets lar ger than the trim length are
> 'trimmed' to the size specified . Packets smaller than the trim length are
> forwarded unchang ed.
> >
> > I tried <xsl:value-of select="normalize-space(./TextRun/Text/@value)"/>,
> but I get error XPTY0004.
> >
> > Can someone explain how I should be properly connecting the
> Text/@value entries in this TextRun so that my words are whole?
> >
> > -Lief

Current Thread