Announcement

Collapse
No announcement yet.

xml tidied with attr. sorted does not work for me

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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 [email protected]ware.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

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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>

          Comment


          • #6
            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

            Comment


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

              Comment


              • #8
                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
                Last edited by Michael Bulgrien; 08-Feb-2011, 12:07 PM.
                BC v4.0.7 build 19761
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                Comment


                • #9
                  Hello Michael,

                  Thanks for the suggestion.

                  Would you be able to send in this pair of sample files to [email protected] ? Please include a link to this forum post for reference.
                  Aaron P Scooter Software

                  Comment


                  • #10
                    I had already sent the file pair several days ago, but got no response. I've resent the files.
                    BC v4.0.7 build 19761
                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                    Comment


                    • #11
                      Thanks. I see the more recent email, and we'll investigate as soon as we can.

                      I believe I've found the older email as well, but I was not sure they were the exact files used in this forum post.
                      Aaron P Scooter Software

                      Comment


                      • #12
                        Any updates?
                        BC v4.0.7 build 19761
                        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                        Comment


                        • #13
                          Hello Michael,

                          Not yet. I have not been able to reproduce any issue with these files.

                          I did have one oddity come up during testing:
                          At one point, I somehow loaded your files (ExpectedResults.xml) with oddly modified server="lines" which ended with ;gt; or similar text, instead of just ending with "Machine Name". I am not sure how this happened, and I have attempted to reproduce it by using a Portable install with your Support and Settings packages loaded from scratch. I believe it was an older set of files I modified manually or had merged with your original sample files (re-saved with the Tidied variant that relabeled < and > characters).

                          In both your original submission with "<" characters and in the latest testing, I have managed to find the problem terminology by switching to Tidied or <default>, and usually one of the first Difference lines has contained the syntax issue. Since Conditions.xml loads fine for all 4 file formats, and ExpectedResults.xml has issues, it must be one of the different lines in ExpectedResults that contains the XML syntax trouble.

                          I would like to reiterate that the latest problem I hit (and was able to find and fix by deleting ;gt I have not been able to reproduce. I just mention it as an example in finding syntax problems with XML files. In your last batch of example files, I am able to open them in all four file formats without issue.

                          Could you include or email a screenshot of the first different section when your files are loaded using the Tidied format and/or Default format? Perhaps our data sets are out of sync.
                          Aaron P Scooter Software

                          Comment


                          • #14
                            Reviewing your latest screencast, it looks like you have trouble loading both sides of the comparison. That would certainly make tracking this down a bit more difficult.

                            Could you perhaps sent a single email (with a link back to this forum post), including all the separate parts of the equation:
                            1) The set of test files
                            2) BCSupport.bcpkg
                            3) BCSettings.bcpkg including all 4 XML rules

                            This way I can make sure I'm dealing with the correct combination of file formats and files. Please send a secondary (no attachment email) letting us know to expect it just in case it is caught by junk mail filters.
                            Aaron P Scooter Software

                            Comment


                            • #15
                              I don't know why I'm being asked for all of this again.

                              On Thursday, February 24, 2011 at 9:31 PM I sent you a mail with screencast and attachments:

                              BCSupport.zip
                              BCSettings.zip (which included the 4 XML rules)

                              On Tuesday, February 22, 2011 9:24 AM I sent you a mail with:

                              XML_Sorted.zip

                              This zip file is the only zip file that I sent with .xml files instead of .xml.txt files and they are the files that fail to load in my environment.

                              If you really need me to resend everything, I will, but it will take me a couple days to do so. I am swamped right now and am going out of town early in the morning.
                              BC v4.0.7 build 19761
                              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                              Comment

                              Working...
                              X