function xsl replace

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

function xsl replace

julien.bittard
Hello

I want to replace in my instance xforms, all value that contains the character '&'. I try to use the function xpath "replace". But it returns null.
I test before with the character 't' because the '&' is a special character and it's more difficult to test:

 <p:processor name="oxf:xslt">
        <p:input name="data" href="#instance"  debug="instance avant"/>
       
        <p:input name="config">
           
            <xsl:stylesheet version="2.0">
               
                <xsl:template match="/">
                        <xsl:value-of select="replace(string(.), 't', '_')"/>
                       
                </xsl:template>
            </xsl:stylesheet>
        </p:input>
                                   
        <p:output name="data" id="instanceREP" debug="instance apres"/>
    </p:processor>

I have this error :
Type class org.orbeon.oxf.common.OXFException
Message Null document for debug 'instance apres'
Location oxf:/formulaires/tryptique-asso/tryptique/test_postal_ville.xpl
Line N/A
Column N/A

Have a idea ?

thank you.



--
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: function xsl replace

Erik Bruchez
Administrator
[hidden email] wrote:

> Hello
>
> I want to replace in my instance xforms, all value that contains the character '&'. I try to use the function xpath "replace". But it returns null.
> I test before with the character 't' because the '&' is a special character and it's more difficult to test:
>
>  <p:processor name="oxf:xslt">
>         <p:input name="data" href="#instance"  debug="instance avant"/>
>        
>         <p:input name="config">
>            
>             <xsl:stylesheet version="2.0">
>                
>                 <xsl:template match="/">
>                         <xsl:value-of select="replace(string(.), 't', '_')"/>
>                        
>                 </xsl:template>
>             </xsl:stylesheet>
>         </p:input>
>                                    
>         <p:output name="data" id="instanceREP" debug="instance apres"/>
>     </p:processor>
>
> I have this error :
> Type class org.orbeon.oxf.common.OXFException
> Message Null document for debug 'instance apres'
> Location oxf:/formulaires/tryptique-asso/tryptique/test_postal_ville.xpl
> Line N/A
> Column N/A
>
> Have a idea ?
What your stylesheet does is output a single text node on its output,
which is certainly not a valid XML document.

Try instead:

<xsl:template match="text()">
   <xsl:value-of select="replace(string(.), 't', '_')"/>
</xsl:template>

Then you also need a generic template copy rule to copy all elements and
attributes in your document:

<xsl:template match="@*|node()" priority="-100">
   <xsl:copy>
     <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>

-Erik



--
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