stripping white space

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

stripping white space

Duane Gran-2
I'm using a modified version of the bizdoc2 sample to edit some  
documents which come in a variety of indented forms.  There are some  
"note" elements which contain white space that is useful when reading  
the XML on the screen, but when rendered in an xforms:textarea the  
white space is preserved.

I've tried to strip the white space using XSL (<xsl:strip-space  
elements="*"/> directive) when loading the documents into eXist as  
well as when creating the view, but nothing seems to remove the white  
space.  Is there an OPS setting that I'm overlooking which may be  
affecting this?  Have others come up with techniques to strip white  
space and carriage returns (which, come to think of it, may be the  
real problem) from elements?

Many thanks in advance.

Duane Gran



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: stripping white space

Alessandro  Vernet
Administrator
On 4/3/06, Duane Gran <[hidden email]> wrote:
> Have others come up with techniques to strip white
> space and carriage returns (which, come to think of it, may be the
> real problem) from elements?

Hi Duane,

Have you tried to use the XPath 2.0 normalize-space() function?

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: stripping white space

Duane Gran-2

On Apr 4, 2006, at 9:02 PM, Alessandro Vernet wrote:

> On 4/3/06, Duane Gran <[hidden email]> wrote:
>> Have others come up with techniques to strip white
>> space and carriage returns (which, come to think of it, may be the
>> real problem) from elements?
>
> Hi Duane,
>
> Have you tried to use the XPath 2.0 normalize-space() function?

Thanks for the suggestion.  I just tried this, but no luck.  The odd  
thing is that any debugging output shows the space stripped, before  
or after I apply the normalize-space() function.  This leads me doubt  
if the debugging can confirm where the problem lies, but I think I'm  
right in transforming the document as it is loaded into eXist.

If it wasn't clear, the problem I have is with source documents like  
the following:

<element>start text
      next line
      another line, indented just for screen
      readability.</element>

The textarea preserves the white space.  If it helps, below is the  
stylesheet I'm using, with the relevant part near the end:

         <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/ 
1999/XSL/Transform">
           <xsl:template match="/">
             <document-info xsl:version="2.0"  
xmlns:uuid="java:org.orbeon.oxf.util.UUIDUtils">
               <document-id>
                 <!-- Create a document id by calling some Java code -->
                 <xsl:value-of select="uuid:createPseudoUUID()"/>
               </document-id>
               <document>
                 <xsl:copy-of select="/*"/>
               </document>
             </document-info>
           </xsl:template>

           <!-- fold newlines in text elements to spaces, etc. -->
           <xsl:template match="text()" priority="2">
             <xsl:value-of select="normalize-space(.)"/>
           </xsl:template>
         </xsl:stylesheet>

Suggestions are most welcome and appreciated.

Duane



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: stripping white space

Alessandro  Vernet
Administrator
On 4/4/06, Duane Gran <[hidden email]> wrote:
> This leads me doubt
> if the debugging can confirm where the problem lies, but I think I'm
> right in transforming the document as it is loaded into eXist.

Duane,

Yes, using "debug" in XPL will reformat XML, and so this is not a good
way to investigate issues with white spaces. You can use a
file-serializer in the pipeline that runs the stylesheet and look at
the serialized data. You can also use <xsl:message>, for instance
changing your stylesheet with something that looks like:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:variable name="result">
            <document-info xsl:version="2.0"
xmlns:uuid="java:org.orbeon.oxf.util.UUIDUtils">
                ...
            </document-info>
        </xsl:variable>
        <xsl:message>Result: <xsl:copy-of select="$result"/></xsl:message>
        <xsl:copy-of select="$result"/>
    </xsl:template>
    ...
</xsl:stylesheet>

I hope this will help at least narrowing down the problem.

Alex
--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet