Go Back   Scooter Forums > Beyond Compare 3 Discussion > File Formats vs. Rules
Register FAQ Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 16-Sep-2010, 06:19 AM
LameSnail LameSnail is offline
Visitor
 
Join Date: Sep 2010
Posts: 3
Default xml tidied with attr. sorted does not work for me

Hi all,

I've used BC 3.1.11 with the plugin "xml tidied with attr. sorted", shown on the left and right side in the file compare window.
At the moment I've noticed a stranged behaviour:
I've compared two xml files (tortoise svn version on the left and 2nd file on the right) which should be nearly the same. But the differences which where shown were much more than I've expected. The reason was that the xml plugin does not sort the attributes.
First I thought this was an effect of the read only file from svn, but I copied the content from the left side to a new file a recompare them. The same effect.
What is my mistake? Do I have to do a retrigger of the comparison process?

Best regards
Michael
Reply With Quote
  #2  
Old 16-Sep-2010, 10:08 AM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,447
Default

Hello,

XML Attributes are not the nodes themselves, but quoted attributes within a node, such as:
<photo src="shasta" id="p001" filetype="gif" />

Sorted attributes would sort src, id and filetype, but would not reorder the node <photo> amongst other nodes.

Are your files having trouble with sorted attributes or nodes? If you are still running into any issues, please let us know. If you could post some example files, or email them to support@scootersoftware.com with your Support.zip (from the Help menu -> Support; Export), we can take a look at them.

Please do not post your Support.zip to the forum, and if you email us, please include a link back to this forum post. Thanks.
__________________
Aaron P Scooter Software
Reply With Quote
  #3  
Old 17-Sep-2010, 12:10 AM
LameSnail LameSnail is offline
Visitor
 
Join Date: Sep 2010
Posts: 3
Default xml tidied with attr. sorted does not work for me

Hi,

am I right that BC3 does not resort the nodes, only the attributes? If it is so, is there a way to preprocess the xml files before I compare them with BC?
If there's no way I'll have to develop a small tool to reorder the nodes.
I'll post you my example in a few minutes.
The first edition of the files will be represent the files in way I get them and they should be compared. The files are nearly equal, but BC3.1.11 shows differences with the plugin "xml with attributes sort".
The second edition of the files will be represent the files in way I sort them by hand and compare them via BC3.1.11. BC3 shows that there are no differences.

Best regards
Michael
Reply With Quote
  #4  
Old 17-Sep-2010, 09:51 AM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,447
Default

Hello,

We received your email and I have sent a response. The issue is that we sort the attributes, not the nodes, with that File Format. In the email is a link to our KB article:
http://www.scootersoftware.com/suppo...rnalconversion

This details how to create a custom conversion process and how to call it with BC3.
__________________
Aaron P Scooter Software
Reply With Quote
  #5  
Old 23-Sep-2010, 05:36 AM
dr_barnowl dr_barnowl is offline
Enthusiast
 
Join Date: Apr 2008
Posts: 47
Default

When I have to sort nodes in an XML document, I write a simple XSLT sheet and use an XSLT parser (like the Saxon.NET Transform.exe program) in the external conversion.

Base the stylesheet on the identity template that copies everything verbatim ...

Code:
<xsl:template match="@* | node()">
   <xsl:copy>
   <xsl:apply-templates select="@* | node()"/>
   <xsl:apply-templates/>
   </xsl:copy>
</xsl:template>
.. and add extra templates that match, sort, and copy the elements you want to sort.

Code:
<xsl:template match="photo">
    <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates>
            <xsl:sort select="@id"/>
        </xsl:apply-templates>
    </xsl:copy>
</xsl:template>
Reply With Quote
  #6  
Old 23-Sep-2010, 05:52 AM
LameSnail LameSnail is offline
Visitor
 
Join Date: Sep 2010
Posts: 3
Default

Hi,

I've used the following xsl:

Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    <xsl:output method="xml" version="1.0" indent="yes" />
    
    <xsl:template match="/"> 
        <xsl:apply-templates/> 
    </xsl:template> 
    
    <xsl:template match="*">
    	<!-- <xsl:preserve-space elements="*"/>   --> 
        <xsl:copy> 
            <xsl:copy-of select="@*"/> 
            <xsl:apply-templates>
                <!-- Sort by name -->
                <xsl:sort select="@name"/>
            </xsl:apply-templates> 
        </xsl:copy> 
    </xsl:template> 
    
     <xsl:template match="text()|comment()|processing-instruction()"> 
        <xsl:copy/> 
    </xsl:template>
    
</xsl:stylesheet>
and use this as eclipse input. So it works for me. I'm not very familar with xsl and the moment I cannot say which version is more generally.
@dr_barnowl: Can you rate my xsl?
It would be important for me to have a very general xsl and not a specific one which I have to adapt everytime I'll get a new xml.
Another problem was that my xsl inserts blank lines, this problem I've corrected by parsing the (transformed) xml and eleminating the blank lines.
But I guess that xsl should be possible to do this job.

Best regards
Michael
Reply With Quote
  #7  
Old 19-Oct-2010, 04:44 PM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,447
Default

Hello,

We've recently added an "XML Sorted and Tidied" file format to our external conversions page based on a general xslt and conversion program. We would be very interested in any feedback:
http://www.scootersoftware.com/downl...kb_moreformats
__________________
Aaron P Scooter Software
Reply With Quote
  #8  
Old 08-Feb-2011, 10:53 AM
Michael Bulgrien Michael Bulgrien is offline
Carpal Tunnel
 
Join Date: Oct 2007
Location: Pennsylvania
Posts: 1,766
Default XML Tidied with Attributes Sorted

First of all, let me say that "XML Tidied with Attributes Sorted" is an awesome plug-in.
However, when two nodes have exactly the same attributes, it would be helpful if the nodes would be sorted by alphabetically:

http://screencast.com/t/y6oXRCtV5l
http://screencast.com/t/xlbSZ6mB

This might need to be accomplished in two steps:
  1. Sort the Attributes
  2. then Sort the Nodes alphabetically

Both XML Sorted and XML Sorted and Tidied blow up on my files:

http://screencast.com/t/QFOvV05f
http://screencast.com/t/NbW8pCHghRg
__________________
BC v3.3.5 build 15075
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Last edited by Michael Bulgrien; 08-Feb-2011 at 11:07 AM.
Reply With Quote
  #9  
Old 11-Feb-2011, 01:51 PM
Aaron Aaron is offline
Team Scooter
 
Join Date: Oct 2007
Location: Madison, WI
Posts: 5,447
Default

Hello Michael,

Thanks for the suggestion.

Would you be able to send in this pair of sample files to support@scootersoftware.com ? Please include a link to this forum post for reference.
__________________
Aaron P Scooter Software
Reply With Quote
  #10  
Old 11-Feb-2011, 06:44 PM
Michael Bulgrien Michael Bulgrien is offline
Carpal Tunnel
 
Join Date: Oct 2007
Location: Pennsylvania
Posts: 1,766
Default

I had already sent the file pair several days ago, but got no response. I've resent the files.
__________________
BC v3.3.5 build 15075
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 03:08 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.