Re: [xsl] spacing issue

Subject: Re: [xsl] spacing issue
From: Spencer Tickner <spencertickner@xxxxxxxxx>
Date: Sat, 4 Jun 2005 14:02:52 -0700
Thanks for the post,

I'm not sure Michael; when you say "don't use indenting" do you mean
in the output declaration (I have already changed this to 'no'), or in
the xslt document itself? I was able to fix the problem using
disable-output-escaping="yes" with &lt; and &gt;. However I get the
feeling that these kinds of things should be avoided.

Either way it is up and looking good, I do appreciate the post.

Cheers,

Spencer

On 6/4/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> The XSLT 2.0 rules on this are rather more precise than the 1.0 rules
> (although the details are in a non-normative note), and the behaviour you
> are seeing is consistent with those rules:
>
> http://www.w3.org/TR/xslt-xquery-serialization/#HTML_INDENT
>
> Basically these rules mean that unrecognized elements are treated as
> block-level elements, not as inline elements.
>
> In effect this means that since you're not using standard HTML, the
standard
> HTML indenting rules don't meet your needs. So the answer seems to be:
don't
> use indenting.
>
> Michael Kay
> http://www.saxonica.com/
>
>
>
> > -----Original Message-----
> > From: Spencer Tickner [mailto:spencertickner@xxxxxxxxx]
> > Sent: 04 June 2005 18:46
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [xsl] spacing issue
> >
> > I have turned indent="yes" to "no", added strip-space elements="*",
> > played with the output method.. I've got it close but still have a
> > space in the brakets due to a carriage return I just cannot get rid
> > of:
> >
> > <p class="para">(
> >        <insert><span class="insert">t.1</span></insert>)&nbsp;
> >        <insert><span class="insert">granting authorization to members
> > to provide accounting services to the public through limited liability
> > partnerships;</span></insert>
> > </p>
> >
> > I realize that <insert> is not a html tag, however we use it as a
> > indexing field for our search engine. So am I correct in assuming that
> > there is no way to tell Saxon that all tags and text between the ()'s
> > must be on one line?
> >
> >
> > On 6/4/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > You're using indent=yes, with the HTML output method, and
> > you're using an
> > > element in your result tree (insert) that isn't defined in
> > HTML, so the
> > > processor doesn't know what the rules are, and is making up its own.
> > >
> > > If this happens with inline elements that are defined in
> > the HTML spec, such
> > > as span, then you have grounds for complaint. But if you're
> > going to use
> > > non-standard HTML, then you should either avoid using the
> > HTML output
> > > method, or avoid indent="yes".
> > >
> > > Michael Kay
> > > http://www.saxonica.com/
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Spencer Tickner [mailto:spencertickner@xxxxxxxxx]
> > > > Sent: 03 June 2005 23:00
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: [xsl] spacing issue
> > > >
> > > > Hi everyone, thank you all in advance for the help,
> > > >
> > > > I am getting strange spaces in my output. A sample of my code
> > > > is below:
> > > >
> > > > XSLT
> > > >
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <xsl:stylesheet version="2.0"
> > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> > > >       <xsl:output method="html" indent="yes"
> > > > omit-xml-declaration="yes"
> > > > encoding="ISO-8859-1" name="html"/>
> > > >
> > > > <xsl:template match="/">
> > > >       <p class="sub">(<xsl:apply-templates
> > > > select="subsectionnumber"/>)&#xA0; <xsl:apply-templates
> > > > select="subsectiontext"/></p>
> > > > </xsl:template>
> > > >
> > > > <xsl:template match="subsectionnumber">
> > > >       <xsl:apply-templates
> > > >
> > select="text()|strong|a|graphic|em|sup|sub|u|insert|br|eacute|hr"/>
> > > > </xsl:template>
> > > >
> > > > <xsl:template match="text()">
> > > >       <xsl:value-of select="."/>
> > > > </xsl:template>
> > > >
> > > > <xsl:template match="insert">
> > > >       <p class="insert"><xsl:apply-templates/></p>
> > > > </xsl:template>
> > > >
> > > > Sample xml
> > > >
> > > > <subsectionnumber><insert>2</insert></subsectionnumber>
> > > > <subsectiontext>Here is some text for subsection
> > 2</subsectiontext>
> > > >
> > > > Output.
> > > >
> > > > Without the insert tags in the above line everything is
> > sweet as some
> > > > kind of sweet candy. However with insert in the xml (and any other
> > > > inline element) I get spaces around my subsectionnumber.
> > > >
> > > > Example
> > > >
> > > > Without <insert>
> > > >
> > > > <p class="sub">(2)&nbsp; A bylaw passed by the board may be
> > > > repealed,</p>
> > > >
> > > > With <insert>
> > > >
> > > > <p class="para">(
> > > >
> > > >         <insert><span class="insert">t.1</span></insert>
> > > >
> > > >                                       )
> > > >                       &nbsp;
> > > >
> > > >             <insert><span class="insert">granting authorization to
> > > > members</span></insert>
> > > >
> > > >          </p>
> > > >
> > > >
> > > > What I need?
> > > >
> > > > Ok, so the code is ugly, I for one am not a stickler for
> > beautifully
> > > > formatted code, however  I have to get rid of the extra
> > space put in
> > > > by the browser for the carriage returns. ie ( t.1 ).
> > > >
> > > > Any help would be great.
> > > >
> > > > Spencer

Current Thread