whitespace

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

whitespace

Bruce D'Arcus
OK, am going back to trying to solve the whitespace problem. This seems
to touch on a number of issues, so let me see what people think.

Let's look at an example template:

   <xsl:template match="mods:originInfo">
     <xsl:param name="prefix"/>
     <xsl:param name="suffix"/>
     <xsl:if test="mods:place">
       <span class="origin">
         <xsl:value-of select="$prefix"/>
         <xsl:apply-templates select="mods:place"/>
         <xsl:apply-templates select="mods:publisher"/>
         <xsl:value-of select="$suffix"/>
       </span>
     </xsl:if>
   </xsl:template>

This is transforming MODS content into an intermediate representation.
The problem is that the prefix and suffix content is placed outside the
wrapper element, so that the result (internally) would be something like:

, <bib:span class="origin">whatever</bib:span>,

This is what causes the whitespace problem, because whitespace only gets
preserved within the bib:span element.

OK, so in theory I could instead do:

<bib:span class="origin">, whatever, </bib:span>

That solves the whitespace issue, but probably introduces side-effects.
       For example, if you assign special font formatting (bold, italic,
etc.) to that content, does that apply to both the prefix and suffix
content AND the actual element content, or just the latter?  If the
latter, then perhaps that suggests the need for:

<bib:span class="origin">, <bib:content>whatever</bib:content>, </bib:span>

And then what about XML output?

Thoughts?

Bruce


Reply | Threaded
Open this post in threaded view
|

Re: whitespace

James Howison
I'm far from sure that I understand ...

The prefix is ", " and the suffix ", " right?

On Mar 25, 2005, at 4:01 PM, Bruce D'Arcus wrote:

> OK, am going back to trying to solve the whitespace problem. This
> seems to touch on a number of issues, so let me see what people think.
>
> Let's look at an example template:
>
>   <xsl:template match="mods:originInfo">
>     <xsl:param name="prefix"/>
>     <xsl:param name="suffix"/>
>     <xsl:if test="mods:place">
>       <span class="origin">
>         <xsl:value-of select="$prefix"/>
>         <xsl:apply-templates select="mods:place"/>
>         <xsl:apply-templates select="mods:publisher"/>
>         <xsl:value-of select="$suffix"/>
>       </span>
>     </xsl:if>
>   </xsl:template>
>
> This is transforming MODS content into an intermediate representation.
> The problem is that the prefix and suffix content is placed outside
> the wrapper element, so that the result (internally) would be
> something like:
>
> , <bib:span class="origin">whatever</bib:span>,

 From the code above it looks to me like the prefix and suffix are
inside the span but when you write it here they are outside.  Why?

> This is what causes the whitespace problem, because whitespace only
> gets preserved within the bib:span element.
>
> OK, so in theory I could instead do:
>
> <bib:span class="origin">, whatever, </bib:span>
>
> That solves the whitespace issue, but probably introduces
> side-effects.       For example, if you assign special font formatting
> (bold, italic, etc.) to that content, does that apply to both the
> prefix and suffix content AND the actual element content, or just the
> latter?  If the latter, then perhaps that suggests the need for:
>
> <bib:span class="origin">, <bib:content>whatever</bib:content>,
> </bib:span>

I like this more because it seems to allow more formating options
later.  ie as a general principle we should, I think, preserve as much
semantic metadata for as long as possible, deferring formatting (eg
blod) for as long as possible (eg here it would be in the css style,
right?)

> And then what about XML output?

I don't understand the question I'm afraid.

--James
+1 315 395 4056
Details: <http://freelancepropaganda.com/jameshowison.vcf>



Reply | Threaded
Open this post in threaded view
|

Re: whitespace

Bruce D'Arcus
On Mar 25, 2005, at 5:02 PM, James Howison wrote:

> From the code above it looks to me like the prefix and suffix are
> inside the span but when you write it here they are outside.  Why?

Just seeing if you're paying attention.

Actually, it was just a mistake.

>> And then what about XML output?
>
> I don't understand the question I'm afraid.

For example, XHTML (or OpenOffice); do you want:

<span class="title">, <span class="content" style="font-style:
italic;">Some Title</span>, </span>

... or:

, <span class="title" style="font-style: italic;">Some Title</span>,

or something else?

Bruce



Reply | Threaded
Open this post in threaded view
|

Re: whitespace

James Howison
On Mar 25, 2005, at 9:51 PM, Bruce D'Arcus wrote:

>
> On Mar 25, 2005, at 5:02 PM, James Howison wrote:
>
>> From the code above it looks to me like the prefix and suffix are
>> inside the span but when you write it here they are outside.  Why?
>
> Just seeing if you're paying attention.
>
> Actually, it was just a mistake.

:)

>>> And then what about XML output?
>>
>> I don't understand the question I'm afraid.
>
> For example, XHTML (or OpenOffice); do you want:
>
> <span class="title">, <span class="content" style="font-style:
> italic;">Some Title</span>, </span>
>
> ... or:
>
> , <span class="title" style="font-style: italic;">Some Title</span>,

The first,  I think, because there's more semantic information
retained.  The trade off is more complicated code and style sheets but
that is what machines are for.

Commas are perhaps not a great example of a prefix and suffix that
you'd want to transform, but if it was brackets or even words, you
definitely would want to transform those too.

--James
+1 315 395 4056
Details: <http://freelancepropaganda.com/jameshowison.vcf>



Reply | Threaded
Open this post in threaded view
|

Re: whitespace

Bruce D'Arcus
On Mar 26, 2005, at 2:37 PM, James Howison wrote:

>> <span class="title">, <span class="content" style="font-style:
>> italic;">Some Title</span>, </span>
>>
>> ... or:
>>
>> , <span class="title" style="font-style: italic;">Some Title</span>,
>
> The first,  I think, because there's more semantic information
> retained.  The trade off is more complicated code and style sheets but
> that is what machines are for.

There are other tradeoffs too.  For example, do we understand CSS
styling information to only apply to the metadata content, or to the
prefix and suffix too?  Or to make things even more of a complicated
PITA, do we have to contemplate allowing separate styling for the
prefix and suffix elements as well?  I sure hope not!

> Commas are perhaps not a great example of a prefix and suffix that
> you'd want to transform, but if it was brackets or even words, you
> definitely would want to transform those too.

The wrapping is partly to have semantic content to grab onto for
formatting, but it's also to better control whitespace (which is
critical for this stuff).

Bruce