Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2011
    Location
    Antwerp
    Posts
    4

    Default XML: ignoring order or elems and attribs

    Is there way to compare XML so that the order of the elements or attributes does not matter.
    So
    <root>
    <elems1/>
    <elems2/>
    </root>
    is equal to
    <root>
    <elems2/>
    <elems1/>
    </root>

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,788

    Default

    If you are familiar with XSLT editing, you can alter our XML Sorted or Sorted and Tidied format to match and sort based on your current XML structure. It is possible the current implementation may meet your needs as well.

    http://www.scootersoftware.com/downl...oreformats_alt

    Once installed, the files are located in the Beyond Compare 3\Helpers directory.
    Aaron P Scooter Software

  3. #3
    Join Date
    Oct 2011
    Location
    Antwerp
    Posts
    4

    Default improved sort?

    For my XML files, the provided sort did not make any changes. Strange
    I found a better one that first sorts the attributes in an element and then sorts the elements

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

    It look like it should work for most XML files.
    See the attached stylesheet

  4. #4
    Join Date
    Jul 2012
    Posts
    3

    Default

    For me also XML sorted and XML Sorted and Tidied didn't work even for simple XML files. I added a seperate thread to this forum asking that question(http://www.scootersoftware.com/vbull...ead.php?t=8851). But I didn't get any replies yet. Why it doesn't work?

  5. #5
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,788

    Default

    Thanks for the sample conversion. It looks like that xslt works great for your files, but strips out any content between nodes (<a>content</a>) and removes any <!-- comments -->. Would you know of a way to preserve this information?
    Aaron P Scooter Software

  6. #6
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,788

    Default

    Sorry for the delay. I have been comparing our current xslt results with koen's example to see if we can have a single, multipurpose xslt that works for a broad range of files. I am not familiar enough with the xslt format to make something like this quickly; our previous xslt conversions have been provided by helpful customers. In the meantime, if you are familiar with xslt, you can alter/edit the one the conversion process uses in the Beyond Compare 3\Helpers\HtmlTidy\ directory: XML_sorted.xslt
    Aaron P Scooter Software

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •