controlling insertion of newlines in output from XQuery

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

controlling insertion of newlines in output from XQuery

Chris Tomlinson-2
Hi,

I've written an extension module that converts strings in a Tibetan transliteration system (EWTS) to HTML that displays the Tibetan using a font family designed for use on the web.

The main function ewts:toHtml() returns a Type.NODE that consists of a top-level <span/> enclosing <span/> elements around each sequence of characters that are in one of the 10 TibetanMachineWeb fonts. There is an auxiallary funtion that returns a <style/> node that defines the font classes that are used in the generated HTML.

As an example, if the function is called like:

    ewts:toHtml("gsung 'bum / ngag dbang blo bzang")

the output is:


<span><nobr><span class="tmw">#=v$</span></nobr><nobr><span class="tmw">-<wbr></wbr>
</span></nobr><nobr><span class="tmw">80v1</span></nobr><nobr><span class="tmw">-<wbr></wbr>
</span></nobr><nobr><span class="tmw">k<wbr></wbr>
</span></nobr><nobr><span class="tmw">-<wbr></wbr>
</span></nobr><nobr><span class="tmw">$#</span></nobr><nobr><span class="tmw">-<wbr></wbr>
</span></nobr><nobr><span class="tmw">+0$</span></nobr><nobr><span class="tmw">-<wbr></wbr>
</span></nobr><nobr><span class="tmw1">R</span><span class="tmw">}</span></nobr><nobr><span class="tmw">-<wbr></wbr>
</span></nobr><nobr><span class="tmw">07$</span></nobr></span>


The problem that I'm having is that there are newlines inserted in the output sent to the browser just before many of the </span> elements and this throws off the spacing when the HTML is rendered by the browser.

If the newlines are removed then the Tibetan text displays correctly.

I've tried normalize-space() but this removes all the newlines and the <span/>, <nobr/> and <wbr/> elements, leaving behind:

    #=v$-80v1-k-$#-+0$-R}-07$
   
Which of course doesn't display as Tibetan.

So the question is how should I approach the generation of the HTML so that I don't have "extraneous" newlines in output?

Thank you for your help,
Chris


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: controlling insertion of newlines in output from XQuery

wolfgangmm
Hi,

the newlines are added by the serializer. You can disable this by
setting the corresponding serialization option in the query:

declare option exist:serialize "indent=no";

Wolfgang


On 9/29/05, Chris Tomlinson <[hidden email]> wrote:

> Hi,
>
> I've written an extension module that converts strings in a Tibetan transliteration system (EWTS) to HTML that displays the Tibetan using a font family designed for use on the web.
>
> The main function ewts:toHtml() returns a Type.NODE that consists of a top-level <span/> enclosing <span/> elements around each sequence of characters that are in one of the 10 TibetanMachineWeb fonts. There is an auxiallary funtion that returns a <style/> node that defines the font classes that are used in the generated HTML.
>
> As an example, if the function is called like:
>
>     ewts:toHtml("gsung 'bum / ngag dbang blo bzang")
>
> the output is:
>
>
> <span><nobr><span class="tmw">#=v$</span></nobr><nobr><span class="tmw">-<wbr></wbr>
> </span></nobr><nobr><span class="tmw">80v1</span></nobr><nobr><span class="tmw">-<wbr></wbr>
> </span></nobr><nobr><span class="tmw">k<wbr></wbr>
> </span></nobr><nobr><span class="tmw">-<wbr></wbr>
> </span></nobr><nobr><span class="tmw">$#</span></nobr><nobr><span class="tmw">-<wbr></wbr>
> </span></nobr><nobr><span class="tmw">+0$</span></nobr><nobr><span class="tmw">-<wbr></wbr>
> </span></nobr><nobr><span class="tmw1">R</span><span class="tmw">}</span></nobr><nobr><span class="tmw">-<wbr></wbr>
> </span></nobr><nobr><span class="tmw">07$</span></nobr></span>
>
>
> The problem that I'm having is that there are newlines inserted in the output sent to the browser just before many of the </span> elements and this throws off the spacing when the HTML is rendered by the browser.
>
> If the newlines are removed then the Tibetan text displays correctly.
>
> I've tried normalize-space() but this removes all the newlines and the <span/>, <nobr/> and <wbr/> elements, leaving behind:
>
>     #=v$-80v1-k-$#-+0$-R}-07$
>
> Which of course doesn't display as Tibetan.
>
> So the question is how should I approach the generation of the HTML so that I don't have "extraneous" newlines in output?
>
> Thank you for your help,
> Chris


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open