The xforms:delete Action

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

The xforms:delete Action

Markku Laine
Hi,


I noticed a small "oddity" in the behavior of the xforms:delete action.

For example, let's say that I have an XML document as below with three  
contacts:
-------------- 8< --------------
<xforms:instance id="contacts-instance">
        <contacts xmlns="">
                <contact>
                        <name>Erik Bruchez</name>
                </contact>
                <contact>
                        <name>Markku Laine</name>
                </contact>
                <contact>
                        <name>Alessandro Vernet</name>
                </contact>
        </contacts>
</xforms:instance>
-------------- 8< --------------


If I delete one of the contacts ("Markku Laine" in this case) using  
the xforms:delete action and then send the XML document to a servlet,  
which prints the inputstream, I get the following result:
-------------- 8< --------------
<?xml version="1.0" encoding="UTF-8"?><contacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 
" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events 
" xmlns:xforms="http://www.w3.org/2002/xforms">
                                        <contact>
                                                <name>Erik Bruchez</name>
                                        </contact>
                                       
                                        <contact>
                                                <name>Alessandro Vernet</name>
                                        </contact>
                                </contacts>
-------------- 8< --------------


Now, what I was expecting was an XML document without an empty line  
between the two contacts. However, the xforms:delete action just  
deleted the contact element, not the following text node (new line)  
kind of related to the deleted contact element. This is probably a  
standard behavior, right?

And why this matters to me? eXist-db seems to be removing this extra  
new line and when I am comparing the one sent with the one retrieved  
from the database --> they do not match 100%. Of course, there are  
work arounds but just out of curiosity I wanted to check whether the  
xforms:delete action is working as it should.

Kind regards


-Markku


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: The xforms:delete Action

Alessandro  Vernet
Administrator
Markku,

On Mon, Oct 19, 2009 at 1:34 AM, Markku Laine <[hidden email]> wrote:
>
> Now, what I was expecting was an XML document without an empty line between
> the two contacts. However, the xforms:delete action just deleted the contact
> element, not the following text node (new line) kind of related to the
> deleted contact element. This is probably a standard behavior, right?

Right.

> And why this matters to me? eXist-db seems to be removing this extra new
> line and when I am comparing the one sent with the one retrieved from the
> database --> they do not match 100%. Of course, there are work arounds but
> just out of curiosity I wanted to check whether the xforms:delete action is
> working as it should.

How are you comparing the XML? Ideally, you'd want a way that ignores
that type of small differences. I have seen something about
xmldiff:compare() on the eXist mailing list. If you are doing the
comparison in eXist, maybe that function could do the trick and ignore
that sort of small differences.

Alex
--
Orbeon Forms - Web forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
My Twitter: http://twitter.com/avernet


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Re: The xforms:delete Action

Markku Laine

On 19.10.2009, at 21.18, Alessandro Vernet wrote:

> How are you comparing the XML? Ideally, you'd want a way that ignores
> that type of small differences. I have seen something about
> xmldiff:compare() on the eXist mailing list. If you are doing the
> comparison in eXist, maybe that function could do the trick and ignore
> that sort of small differences.

I am using a modified version of Tancred Lindholm's three-way XML  
merging tool: http://www.hiit.fi/files/fi/fc/papers/doceng04-pc.pdf

I solved the problem regarding to empty lines by applying this  
stylesheet (see below) to all three XML documents before executing the  
three-way XML merging:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
                                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                xmlns:saxon="http://saxon.sf.net/"
                                exclude-result-prefixes="saxon">
        <!-- Define the output format -->
        <xsl:output method="xml" version="1.0" indent="yes" saxon:indent-
spaces="4" />
        <xsl:strip-space elements="*" />

        <xsl:template match="/">
                <xsl:copy-of select="." />
        </xsl:template>

</xsl:stylesheet>

Regards


-Markku


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: The xforms:delete Action

Alessandro  Vernet
Administrator
Markku,

On Tue, Oct 20, 2009 at 7:46 AM, Markku Laine <[hidden email]> wrote:

>> I solved the problem regarding to empty lines by applying this stylesheet
> (see below) to all three XML documents before executing the three-way XML
> merging:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0"
>
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                                xmlns:saxon="http://saxon.sf.net/"
>                                exclude-result-prefixes="saxon">
>        <!-- Define the output format -->
>        <xsl:output method="xml" version="1.0" indent="yes"
> saxon:indent-spaces="4" />
>        <xsl:strip-space elements="*" />
>
>        <xsl:template match="/">
>                <xsl:copy-of select="." />
>        </xsl:template>
>
> </xsl:stylesheet>
This looks like a good idea to me, and it is certainly more rebust
than having to remember to change every <xforms:delete> to make sure
to delete some text nodes when you delete an element.

Alex
--
Orbeon Forms - Web forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
My Twitter: http://twitter.com/avernet


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet