You can subscribe to this list here.
2007 |
Jan
|
Feb
(3) |
Mar
(18) |
Apr
(39) |
May
(15) |
Jun
(12) |
Jul
(3) |
Aug
(23) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(21) |
Feb
(23) |
Mar
(33) |
Apr
(8) |
May
(1) |
Jun
(22) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(6) |
Nov
|
Dec
(11) |
2009 |
Jan
(5) |
Feb
|
Mar
(2) |
Apr
(24) |
May
(36) |
Jun
(18) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(3) |
Nov
(1) |
Dec
|
2010 |
Jan
(5) |
Feb
(3) |
Mar
|
Apr
(15) |
May
(24) |
Jun
(11) |
Jul
(8) |
Aug
(34) |
Sep
(42) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(13) |
Feb
(32) |
Mar
(35) |
Apr
(31) |
May
(33) |
Jun
(30) |
Jul
(32) |
Aug
(31) |
Sep
(30) |
Oct
(31) |
Nov
(32) |
Dec
(31) |
2012 |
Jan
(35) |
Feb
(31) |
Mar
(31) |
Apr
(30) |
May
(31) |
Jun
(34) |
Jul
(23) |
Aug
(30) |
Sep
(30) |
Oct
(29) |
Nov
(30) |
Dec
(32) |
2013 |
Jan
(25) |
Feb
(39) |
Mar
(1) |
Apr
(18) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(20) |
Sep
(41) |
Oct
(32) |
Nov
(9) |
Dec
(31) |
2014 |
Jan
(31) |
Feb
(30) |
Mar
(34) |
Apr
(60) |
May
(31) |
Jun
(28) |
Jul
(32) |
Aug
(28) |
Sep
(26) |
Oct
(32) |
Nov
(43) |
Dec
(115) |
2015 |
Jan
(106) |
Feb
(101) |
Mar
(51) |
Apr
(32) |
May
(63) |
Jun
(18) |
Jul
|
Aug
(18) |
Sep
|
Oct
(1) |
Nov
(84) |
Dec
(63) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(104) |
Apr
(30) |
May
(6) |
Jun
(30) |
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(48) |
Dec
(22) |
2017 |
Jan
(15) |
Feb
(29) |
Mar
(43) |
Apr
(29) |
May
(25) |
Jun
(28) |
Jul
(62) |
Aug
(35) |
Sep
(35) |
Oct
(72) |
Nov
(10) |
Dec
(4) |
2018 |
Jan
(7) |
Feb
(4) |
Mar
|
Apr
(46) |
May
(20) |
Jun
(12) |
Jul
(9) |
Aug
(42) |
Sep
(4) |
Oct
(17) |
Nov
(32) |
Dec
(31) |
2019 |
Jan
(21) |
Feb
(14) |
Mar
|
Apr
(74) |
May
(25) |
Jun
(43) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(10) |
2020 |
Jan
(1) |
Feb
|
Mar
(26) |
Apr
(8) |
May
(62) |
Jun
(4) |
Jul
(25) |
Aug
|
Sep
(21) |
Oct
(24) |
Nov
(26) |
Dec
(9) |
2021 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(11) |
Nov
(1) |
Dec
(12) |
2022 |
Jan
(47) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(14) |
2023 |
Jan
(3) |
Feb
|
Mar
(60) |
Apr
(9) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
(5) |
Feb
|
Mar
|
Apr
(10) |
May
(1) |
Jun
|
Jul
|
Aug
(17) |
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
|
Mar
(88) |
Apr
(64) |
May
(47) |
Jun
(20) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <bo...@us...> - 2013-02-03 12:40:28
|
Revision: 515 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=515&view=rev Author: bodewig Date: 2013-02-03 12:40:21 +0000 (Sun, 03 Feb 2013) Log Message: ----------- XSLTC throws an NPE when creating the user guide, use xsltproc Modified Paths: -------------- branches/xmlunit-1.x/docbook.xml Modified: branches/xmlunit-1.x/docbook.xml =================================================================== --- branches/xmlunit-1.x/docbook.xml 2013-02-03 11:29:17 UTC (rev 514) +++ branches/xmlunit-1.x/docbook.xml 2013-02-03 12:40:21 UTC (rev 515) @@ -37,6 +37,7 @@ <!-- location of Docbook Stylesheets and dblatex --> <property name="db5.xsl" location="../../docbook/docbook5-xsl-1.72.0"/> <property name="dblatex" value="/usr/bin/dblatex"/> + <property name="xsltproc" value="/usr/bin/xsltproc"/> <property name="html.dir" location="${userguide.docs.dir}/html"/> <property name="user.guide" value="XMLUnit-Java"/> @@ -52,11 +53,36 @@ targetfile="${html.dir}/index.html"/> </target> - <target name="users-guide-html" depends="-html-needs-refresh?" - unless="HTML is up-to-date" - description="Creates HTML version of the User's Guide"> + <target name="-xsltproc-available?" depends="-html-needs-refresh?"> + <available property="xsltproc available" + file="${xsltproc}"/> + <condition property="run TraX"> + <not> + <or> + <isset property="xsltproc available"/> + <isset property="HTML is up-to-date"/> + </or> + </not> + </condition> + <condition property="run xsltproc"> + <and> + <isset property="xsltproc available"/> + <not> + <isset property="HTML is up-to-date"/> + </not> + </and> + </condition> + </target> + + <target name="-users-guide-html-pre" depends="-html-needs-refresh?" + unless="HTML is up-to-date"> <delete dir="${html.dir}" quiet="true"/> <mkdir dir="${html.dir}"/> + </target> + + <target name="-users-guide-html-trax" + depends="-xsltproc-available?,-users-guide-html-pre" + if="run TraX"> <xslt basedir="${src.userguide.dir}" destdir="${html.dir}" @@ -66,10 +92,34 @@ <param name="section.autolabel" expression="1"/> <param name="section.label.includes.component.label" expression="1"/> </xslt> - <copy file="${src.dir}/site/xmlunit.png" toDir="${html.dir}"/> <delete file="${html.dir}/${user.guide}.html" quiet="true"/> </target> + <target name="-users-guide-html-xsltproc" + depends="-xsltproc-available?,-users-guide-html-pre" + if="run xsltproc"> + <exec command="${xsltproc}" failonerror="true"> + <arg value="-o"/> + <!-- xsltproc needs the trailing slash to work properly --> + <arg value="${html.dir}/"/> + <arg value="--param"/> + <arg value="section.autolabel"/> + <arg value="1"/> + <arg value="--param"/> + <arg value="section.label.includes.component.label"/> + <arg value="1"/> + <arg file="${db5.xsl}/html/chunk.xsl"/> + <arg file="${src.userguide.dir}/${user.guide}.xml"/> + </exec> + </target> + + <target name="users-guide-html" + depends="-users-guide-html-trax,-users-guide-html-xsltproc" + unless="HTML is up-to-date" + description="Creates HTML version of the User's Guide"> + <copy file="${src.dir}/site/xmlunit.png" toDir="${html.dir}"/> + </target> + <target name="-check-os"> <condition property="isWindows"> <os family="windows"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 11:29:24
|
Revision: 514 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=514&view=rev Author: bodewig Date: 2013-02-03 11:29:17 +0000 (Sun, 03 Feb 2013) Log Message: ----------- somehow forgot Apache License 1.1 requires boilerplate license everywhere Modified Paths: -------------- branches/xmlunit-1.x/docbook.xml branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml Modified: branches/xmlunit-1.x/docbook.xml =================================================================== --- branches/xmlunit-1.x/docbook.xml 2013-02-03 11:25:27 UTC (rev 513) +++ branches/xmlunit-1.x/docbook.xml 2013-02-03 11:29:17 UTC (rev 514) @@ -1,3 +1,35 @@ +<!-- +Copyright (c) 2001-2013, Jeff Martin, Tim Bacon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> <project> <!-- allow overrides --> <property file="docbook.properties"/> Modified: branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml =================================================================== --- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2013-02-03 11:25:27 UTC (rev 513) +++ branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2013-02-03 11:29:17 UTC (rev 514) @@ -1,6 +1,38 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE article PUBLIC "-//OASIS//DTD Simplified DocBook XML V1.1b1//EN" "http://docbook.org/xml/simple/1.1b1/sdocbook.dtd"> +<!-- +Copyright (c) 2001-2013, Jeff Martin, Tim Bacon +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +--> + <article> <title>XMLUnit Java User's Guide <inlinemediaobject><imageobject> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 11:25:33
|
Revision: 513 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=513&view=rev Author: bodewig Date: 2013-02-03 11:25:27 +0000 (Sun, 03 Feb 2013) Log Message: ----------- improve PDF generation Modified Paths: -------------- branches/xmlunit-1.x/docbook.xml Property Changed: ---------------- branches/xmlunit-1.x/ branches/xmlunit-1.x/src/user-guide/ Property changes on: branches/xmlunit-1.x ___________________________________________________________________ Modified: svn:ignore - build + build build.properties docbook.properties Modified: branches/xmlunit-1.x/docbook.xml =================================================================== --- branches/xmlunit-1.x/docbook.xml 2013-02-03 11:24:34 UTC (rev 512) +++ branches/xmlunit-1.x/docbook.xml 2013-02-03 11:25:27 UTC (rev 513) @@ -77,6 +77,7 @@ <target name="users-guide-pdf" depends="-define-dblatex" description="Creates the PDF version of the User's Guide"> + <copy file="${src.dir}/site/xmlunit.png" toDir="${src.userguide.dir}"/> <dblatex sourcefile="${src.userguide.dir}/${user.guide}.xml"/> <move file="${src.userguide.dir}/${user.guide}.pdf" todir="${userguide.docs.dir}"/> Property changes on: branches/xmlunit-1.x/src/user-guide ___________________________________________________________________ Added: svn:ignore + xmlunit.png This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 11:24:40
|
Revision: 512 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=512&view=rev Author: bodewig Date: 2013-02-03 11:24:34 +0000 (Sun, 03 Feb 2013) Log Message: ----------- document changes for 1.4 Modified Paths: -------------- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml Modified: branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml =================================================================== --- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2013-02-03 11:06:30 UTC (rev 511) +++ branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2013-02-03 11:24:34 UTC (rev 512) @@ -44,6 +44,11 @@ <date>September 2009</date> <revremark>Documentation for XMLUnit Java 1.3</revremark> </revision> + <revision> + <revnumber>1.4</revnumber> + <date>February 2013</date> + <revremark>Documentation for XMLUnit Java 1.4</revremark> + </revision> </revhistory> </articleinfo> @@ -3618,7 +3623,7 @@ <section id="Changes 1.4"> <title>Changes from XMLUnit 1.3 to 1.4</title> - <section id="Breaking Changes 1.3"> + <section id="Breaking Changes 1.4"> <title>Breaking Changes</title> <!--itemizedlist> @@ -3628,8 +3633,14 @@ <section id="New Features 1.4"> <title>New Features</title> - <!--itemizedlist> - </itemizedlist--> + <itemizedlist> + <listitem> + xsi:type attributes now have their value interpreted as a + QName and will compare as identical if their namespace URI + and local names match even if they use different + prefixes. <ulink url="https://sourceforge.net/tracker/?func=detail&aid=3602981&group_id=23187&atid=377771">Issue 3602981</ulink> + </listitem> + </itemizedlist> </section> <section id="Bugfixes 1.4"> @@ -3642,6 +3653,15 @@ exception when at least one XPath matched an attribute. <ulink url="https://sourceforge.net/tracker/?func=detail&aid=3290264&group_id=23187&atid=377768">Issue 377768</ulink>. </listitem> + + <listitem> + <literal>FloatingPointTolerantDifferenceListener</literal> + expected numbers to differ by less than the given + tolerance rather than "less or equal" than as the docs said. + <ulink + href="https://sourceforge.net/tracker/index.php?func=detail&aid=3593368&group_id=23187&atid=377768">Issue + 3593368</ulink> + </listitem> </itemizedlist> </section> </section> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 11:06:36
|
Revision: 511 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=511&view=rev Author: bodewig Date: 2013-02-03 11:06:30 +0000 (Sun, 03 Feb 2013) Log Message: ----------- merge fix for issue 3593368 Modified Paths: -------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java Property Changed: ---------------- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java Modified: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java =================================================================== --- trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2013-02-03 10:48:45 UTC (rev 510) +++ trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2013-02-03 11:06:30 UTC (rev 511) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2008, Jeff Martin, Tim Bacon +Copyright (c) 2008,2013 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -60,7 +60,7 @@ try { double controlVal = Double.parseDouble(control); double testVal = Double.parseDouble(test); - return Math.abs(controlVal - testVal) < tolerance + return Math.abs(controlVal - testVal) <= tolerance ? DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL : DifferenceListener.RETURN_ACCEPT_DIFFERENCE; } catch (NumberFormatException nfe) { Property changes on: trunk/xmlunit/src/main/java-legacy/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java:346,353,494,510 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2013-02-03 10:56:35
|
Bugs item #3472779, was opened at 2012-01-11 19:16 Message generated for change (Settings changed) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3472779&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.3 >Status: Pending Resolution: None Priority: 5 Private: No Submitted By: z_kvn (zkev) Assigned to: Nobody/Anonymous (nobody) Summary: MatchTracker unable to catch CHILD_NODE_NOT_FOUND_ID Initial Comment: Setup a comparison with both DifferenceListener and MatchTracker for DifferenceConstants.CHILD_NODE_NOT_FOUND_ID Somehow DifferenceListener is able to catch DifferenceConstants.CHILD_NODE_NOT_FOUND_ID ( int value 22) while MatchTracker will not be able to get notified. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2012-01-12 05:51 Message: I'm not quite sure I understand wha you are looking for. CHILD_NODE_NOT_FOUND is a bit different from the other types of differences as it aways only describes a difference - unlike, say, ATTR_VALUE which describes a comparison performed by XMLUnit (of attribute values in this case). CHILD_NODE_NOT_FOUND is raised if XMLUnit cannot find a child of the test node that matches a certain child of the control node (or vice versa). What are the circumstances where you'd expect the MatchTracker to get noitified? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3472779&group_id=23187 |
From: SourceForge.net <no...@so...> - 2013-02-03 10:55:59
|
Bugs item #2094508, was opened at 2008-09-04 23:46 Message generated for change (Settings changed) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2094508&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.1 >Status: Closed Resolution: Wont Fix Priority: 1 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: HTMLDocumentBuilder and Java 1.6 Initial Comment: HTMLDocumentBuilder fails to parse following (one line) HTML correctly if Java 1.6 is used. Only one of input elements finds its way into the document. It works correctly with Java 1.5. If you add a space between </script> and <input> tags it works also with Java 1.6. String html = "<html><head><title>Test</title></head><form action=\"\"><script language=\"javascript\">alert('test');</script><input type=\"text\"/><input type=\"button\"/></form></html>"; TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder = new TolerantSaxDocumentBuilder(XMLUnit.newTestParser()); HTMLDocumentBuilder htmlDocumentBuilder = new HTMLDocumentBuilder(tolerantSaxDocumentBuilder); Document document = htmlDocumentBuilder.parse(html); ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2008-10-09 06:27 Message: I can reproduce this, but it is most likely due to changes in javax.swing.html.parser.* - something that I'm personally not familiar with and honestly don't want to become familiar with either. I'd recommend you use a library other than XMLUnit to turn HTML into proper XML since those other libraries do a better job at it anyway. I can't recommend a specific library, but options I've seen used include JTidy <http://jtidy.sourceforge.net/>, TagSoup <http://ccil.org/~cowan/XML/tagsoup/> and NekoHTML <http://nekohtml.sourceforge.net/>. Unless anybody feels like contributing a patch (including tests), this won't get fixes. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2094508&group_id=23187 |
From: SourceForge.net <no...@so...> - 2013-02-03 10:54:37
|
Bugs item #2946497, was opened at 2010-02-05 03:56 Message generated for change (Settings changed) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2946497&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.2 >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: Error for xmls with different child & attr sequence Initial Comment: I have two xmls XML 1 <root> <Override ContentType="slideLayout+xml" PartName="slideLayout1.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout8.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout7.xml" /> </root> XML 2 <root> <Override ContentType="slideLayout+xml" PartName="slideLayout8.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout1.xml" /> <Override ContentType="slideLayout+xml" PartName="slideLayout7.xml" /> </root> XML 3 <root> <Override PartName="slideLayout8.xml" ContentType="slideLayout+xml" /> <Override PartName="slideLayout1.xml" ContentType="slideLayout+xml" /> <Override PartName="slideLayout7.xml" ContentType="slideLayout+xml" /> </root> Accordingly to me all the xmls are equal. I tried using TestCase.java (attached here) to compare them. I tried to compare these two xmls ignoring both the child sequence as well as the attribute sequence, but xml unit still complains they are different. Here is the source code I tried, please let me know what changes do I do my source in order to make XMLUnit say the three xml files are equal. import java.io.IOException; import java.util.List; import org.custommonkey.xmlunit.DetailedDiff; import org.custommonkey.xmlunit.Difference; import org.custommonkey.xmlunit.DifferenceConstants; import org.custommonkey.xmlunit.DifferenceListener; import org.custommonkey.xmlunit.XMLTestCase; import org.w3c.dom.Node; import org.xml.sax.SAXException; /** * @author rohitghatol * */ public class TestCase extends XMLTestCase { public static final String TAB = " "; private static final String leftSnippet = "<root><Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout1.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout8.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout7.xml\" /> </root>"; private static final String rightSnippet = "<root><Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout8.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout1.xml\" /> <Override ContentType=\"slideLayout+xml\" PartName=\"slideLayout7.xml\" /> </root>"; public void compareString(final String leftContent, final String rightContent) throws SAXException, IOException { final DetailedDiff myDiff = new DetailedDiff(compareXML(leftContent, rightContent)); myDiff.overrideDifferenceListener(new NoSequenceDifferenceListener()); final List<Difference> allDifferences = myDiff.getAllDifferences(); if ( (null == allDifferences) || (allDifferences.size() <= 0) ) { System.out.println(TAB + "No Difference found"); } else { System.out.println(TAB + allDifferences.size() + " number of difference found"); } int index = 0; for ( final Difference diff : allDifferences ) { System.out.println(TAB + ":" + (index++) + ": Difference = " + diff); } System.out.println("======================================================="); } private class NoSequenceDifferenceListener implements DifferenceListener { /* * (non-Javadoc) * @see org.custommonkey.xmlunit.DifferenceListener#differenceFound(org.custommonkey.xmlunit.Difference) */ @Override public int differenceFound(final Difference diff) { int returnVal = DifferenceListener.RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; switch ( diff.getId() ) { case DifferenceConstants.ATTR_SEQUENCE_ID: case DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID: returnVal = DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; break; default: returnVal = DifferenceListener.RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT; } return returnVal; } /* * (non-Javadoc) * @see org.custommonkey.xmlunit.DifferenceListener#skippedComparison(org.w3c.dom.Node, org.w3c.dom.Node) */ @Override public void skippedComparison(final Node node1, final Node node2) { System.out.println("---> node1 " + node1.getLocalName()); } } public static void main(final String[] args) throws SAXException, IOException { final TestCase testcase = new TestCase(); testcase.compareString(leftSnippet, rightSnippet); } } ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2010-02-08 04:33 Message: Your problem is not related to attribute order at all, XMLUnit is just not comparing the elements you want it to compare, Dy default it will match XML elements by their name and since in your case all elements have the same name it will compare them in order. What you want is to tell XMLUnit it should only compare the elements that have the same name and the same PartName attribute. To do so, you'd use an ElementNameAndAttributeQualifier - see http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#ElementNameAndAttributeQualifier ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=2946497&group_id=23187 |
From: SourceForge.net <no...@so...> - 2013-02-03 10:49:39
|
Bugs item #3593368, was opened at 2012-12-06 15:21 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3593368&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Pending >Resolution: Fixed Priority: 5 Private: No Submitted By: david rees (reesd) Assigned to: Nobody/Anonymous (nobody) Summary: FloatingPointTolerantDifferenceListener should use <= Initial Comment: FloatingPointTolerantDifferenceListener should have line 63 updated as follows so it uses <= for comparing its values rather than <. return Math.abs(controlVal - testVal) < tolerance This would make it more consistent with its description "if they only differ by a given tolerance value (or less)". I also will expand its usefulness to the larger case of values that are textually different but numerically equal (e.g 0 = 0.0, 0.1000 = 0.1). ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2013-02-03 02:49 Message: fixed with svn revision 510, will be fixed in XMLUnit 1.4. Thanks ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3593368&group_id=23187 |
From: <bo...@us...> - 2013-02-03 10:48:51
|
Revision: 510 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=510&view=rev Author: bodewig Date: 2013-02-03 10:48:45 +0000 (Sun, 03 Feb 2013) Log Message: ----------- make FloatingPointTolerantDifferenceListener do what the docs say, Issue 3593368 Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2013-02-03 10:21:27 UTC (rev 509) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/examples/FloatingPointTolerantDifferenceListener.java 2013-02-03 10:48:45 UTC (rev 510) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2008, Jeff Martin, Tim Bacon +Copyright (c) 2008,2013 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -60,7 +60,7 @@ try { double controlVal = Double.parseDouble(control); double testVal = Double.parseDouble(test); - return Math.abs(controlVal - testVal) < tolerance + return Math.abs(controlVal - testVal) <= tolerance ? DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL : DifferenceListener.RETURN_ACCEPT_DIFFERENCE; } catch (NumberFormatException nfe) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2013-02-03 10:43:34
|
Feature Requests item #3602981, was opened at 2013-02-01 07:05 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=3602981&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Pending >Resolution: Fixed Priority: 5 Private: No Submitted By: David Portabella Clotet (dportabella) Assigned to: Nobody/Anonymous (nobody) Summary: Diff failswith xsi:type and different prefix Initial Comment: This code: import org.custommonkey.xmlunit.Diff; String result = "<ns1:Square xsi:type=\"ns1:Shape\" xmlns:ns1=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; String correct = "<ns2:Square xsi:type=\"ns2:Shape\" xmlns:ns2=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; Diff diff = new Diff(result, correct); System.out.println("diff:" + diff); System.out.println("diff.similar(): " + diff.similar()); results in: diff: org.custommonkey.xmlunit.Diff [not identical] Expected namespace prefix 'ns1' but was 'ns2' - comparing <ns1:Square...> at /Square[1] to <ns2:Square...> at /Square[1] [different] Expected attribute value 'ns1:Shape' but was 'ns2:Shape' - comparing <ns1:Square xsi:type="ns1:Shape"...> at /Square[1]/@type to <ns2:Square xsi:type="ns2:Shape"...> at /Square[1]/@type diff.similar(): false --- someone posted a fix here: http://stackoverflow.com/questions/14647861/xmlunit-diff-returns-similar-false-if-there-is-a-xsitype-and-a-different-namesp/14648786#14648786 ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2013-02-03 02:43 Message: The only remaining xsi-attribute is xsi:nil which - I think - is handled reasonably. I'm preparing a new release, would be good if you could test the fix before I finalize it. If you have any trouble building XMLUnit from source, I'll be happy to provide a binary. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2013-02-02 06:53 Message: This should be fixed with svn revision 502 in the 1.x Branch https://xmlunit.svn.sourceforge.net/svnroot/xmlunit/branches/xmlunit-1.x Can you try to build it yourself to see whether it works for you? Before I cut a new release I want to look around the Schema Instance namespace to see whether there is anything else XMLUnit could support in a better way. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2013-02-01 08:22 Message: Actually, XMLUnit doesn't really support much of the XML-Schema Instance stuff at all. I've started to fix it in the 1.x branch and simply ignoring the namespace prefix is trivial for this case, making sure the prefixes map to the same NS uris seems more difficult, at least as long as I'm in Java 1.4 land. Once this is fixed I'll roll a new release. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377771&aid=3602981&group_id=23187 |
From: <bo...@us...> - 2013-02-03 10:21:33
|
Revision: 509 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=509&view=rev Author: bodewig Date: 2013-02-03 10:21:27 +0000 (Sun, 03 Feb 2013) Log Message: ----------- typo Modified Paths: -------------- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml Modified: branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml =================================================================== --- branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2013-02-03 10:20:06 UTC (rev 508) +++ branches/xmlunit-1.x/src/user-guide/XMLUnit-Java.xml 2013-02-03 10:21:27 UTC (rev 509) @@ -3639,7 +3639,7 @@ <listitem> <literal>XMLTestCase</literal>'s and <literal>XMLAssert</literal>'s <literal>assertXpathsEqual</literal> methods threw an - exception at least one XPath matched an attribute. <ulink + exception when at least one XPath matched an attribute. <ulink url="https://sourceforge.net/tracker/?func=detail&aid=3290264&group_id=23187&atid=377768">Issue 377768</ulink>. </listitem> </itemizedlist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 10:20:13
|
Revision: 508 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=508&view=rev Author: bodewig Date: 2013-02-03 10:20:06 +0000 (Sun, 03 Feb 2013) Log Message: ----------- backport xsi:nil test Modified Paths: -------------- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java Property Changed: ---------------- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-02-03 10:17:50 UTC (rev 507) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-02-03 10:20:06 UTC (rev 508) @@ -975,5 +975,14 @@ Diff diff = new Diff(control, test); assertFalse(diff.toString(), diff.similar()); } + public void testXsiNil() throws Exception { + String test = "<foo xsi:nil=\"true\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<foo xsi:nil=\"false\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertFalse(diff.toString(), diff.similar()); + } } Property changes on: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java ___________________________________________________________________ Added: svn:mergeinfo + /trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java:507 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 10:17:56
|
Revision: 507 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=507&view=rev Author: bodewig Date: 2013-02-03 10:17:50 +0000 (Sun, 03 Feb 2013) Log Message: ----------- xsi:nil test for legacy API Modified Paths: -------------- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2013-02-03 10:14:36 UTC (rev 506) +++ trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2013-02-03 10:17:50 UTC (rev 507) @@ -1049,5 +1049,14 @@ assertFalse(diff.toString(), diff.similar()); } + public void testXsiNil() throws Exception { + String test = "<foo xsi:nil=\"true\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<foo xsi:nil=\"false\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertFalse(diff.toString(), diff.similar()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 10:14:43
|
Revision: 506 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=506&view=rev Author: bodewig Date: 2013-02-03 10:14:36 +0000 (Sun, 03 Feb 2013) Log Message: ----------- Post xsi:type changes to .NET version Modified Paths: -------------- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs trunk/xmlunit/src/main/net-core/diff/XPathContext.cs trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs trunk/xmlunit/src/tests/net-core/diff/XPathContextTest.cs Modified: trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2013-02-03 09:41:49 UTC (rev 505) +++ trunk/xmlunit/src/main/net-core/diff/DOMDifferenceEngine.cs 2013-02-03 10:14:36 UTC (rev 506) @@ -424,6 +424,12 @@ } } + lastResult = CompareXsiType(controlAttributes.Type, controlContext, + testAttributes.Type, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + lastResult = Compare(new Comparison(ComparisonType.SCHEMA_LOCATION, control, GetXPath(controlContext), @@ -571,7 +577,69 @@ return lastResult; } + /// <summary> + /// Compares xsi:type attribute values + /// </summary> + private ComparisonResult CompareXsiType(XmlAttribute control, + XPathContext controlContext, + XmlAttribute test, + XPathContext testContext) { + bool mustChangeControlContext = control != null; + bool mustChangeTestContext = test != null; + if (!mustChangeControlContext && !mustChangeTestContext) { + return ComparisonResult.EQUAL; + } + + try { + if (mustChangeControlContext) { + XmlQualifiedName q = Nodes.GetQName(control); + controlContext.AddAttribute(q); + controlContext.NavigateToAttribute(q); + } + if (mustChangeTestContext) { + XmlQualifiedName q = Nodes.GetQName(test); + testContext.AddAttribute(q); + testContext.NavigateToAttribute(q); + } + ComparisonResult lastResult = + Compare(new Comparison(ComparisonType.ATTR_NAME_LOOKUP, + control, GetXPath(controlContext), + mustChangeControlContext, + test, GetXPath(testContext), + mustChangeTestContext)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + if (mustChangeControlContext && mustChangeTestContext) { + lastResult = + CompareAttributeExplicitness(control, controlContext, + test, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + XmlQualifiedName controlQName = ValueAsQName(control); + XmlQualifiedName testQName = ValueAsQName(test); + lastResult = + Compare(new Comparison(ComparisonType.ATTR_VALUE, + control, + GetXPath(controlContext), + controlQName.ToString(), + test, GetXPath(testContext), + testQName.ToString())); + } + return lastResult; + } finally { + if (mustChangeControlContext) { + controlContext.NavigateToParent(); + } + if (mustChangeTestContext) { + testContext.NavigateToParent(); + } + } + } + + /// <summary> /// Compares properties of an attribute. /// </summary> private ComparisonResult CompareAttributes(XmlAttribute control, @@ -580,11 +648,8 @@ XPathContext testContext) { ComparisonResult lastResult = - Compare(new Comparison(ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED, - control, GetXPath(controlContext), - control.Specified, - test, GetXPath(testContext), - test.Specified)); + CompareAttributeExplicitness(control, controlContext, + test, testContext); if (lastResult == ComparisonResult.CRITICAL) { return lastResult; @@ -598,6 +663,22 @@ } /// <summary> + // Compares whether two attributes are specified explicitly. + /// </summary> + private ComparisonResult + CompareAttributeExplicitness(XmlAttribute control, + XPathContext controlContext, + XmlAttribute test, + XPathContext testContext) { + return + Compare(new Comparison(ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED, + control, GetXPath(controlContext), + control.Specified, + test, GetXPath(testContext), + test.Specified)); + } + + /// <summary> /// Separates XML namespace related attributes from "normal" /// attributes. /// </summary> @@ -608,26 +689,49 @@ XmlAttribute nNsLoc = map.GetNamedItem("noNamespaceSchemaLocation", XmlSchema.InstanceNamespace) as XmlAttribute; + XmlAttribute type = map.GetNamedItem("type", + XmlSchema.InstanceNamespace) + as XmlAttribute; List<XmlAttribute> rest = new List<XmlAttribute>(); foreach (XmlAttribute a in map) { - if (XmlSchema.InstanceNamespace != a.NamespaceURI - && - "http://www.w3.org/2000/xmlns/" != a.NamespaceURI) { + if ("http://www.w3.org/2000/xmlns/" != a.NamespaceURI + && a != sLoc && a != nNsLoc && a != type) { rest.Add(a); } } - return new Attributes(sLoc, nNsLoc, rest); + return new Attributes(sLoc, nNsLoc, type, rest); } + private static XmlQualifiedName ValueAsQName(XmlAttribute attribute) { + // split QName into prefix and local name + string[] pieces = attribute.Value.Split(':'); + if (pieces.Length < 2) { + // unprefixed name + pieces = new string[] { string.Empty, pieces[0] }; + } else if (pieces.Length > 2) { + // actually, this is not a valid QName - be lenient + pieces = new string[] { + pieces[0], + attribute.Value.Substring(pieces[0].Length + 1) + }; + } + return new XmlQualifiedName(pieces[1] ?? string.Empty, + attribute + .GetNamespaceOfPrefix(pieces[0])); + } + internal class Attributes { internal readonly XmlAttribute SchemaLocation; internal readonly XmlAttribute NoNamespaceSchemaLocation; + internal readonly XmlAttribute Type; internal readonly IList<XmlAttribute> RemainingAttributes; internal Attributes(XmlAttribute schemaLocation, XmlAttribute noNamespaceSchemaLocation, + XmlAttribute type, IList<XmlAttribute> remainingAttributes) { this.SchemaLocation = schemaLocation; this.NoNamespaceSchemaLocation = noNamespaceSchemaLocation; + this.Type = type; this.RemainingAttributes = remainingAttributes; } } Modified: trunk/xmlunit/src/main/net-core/diff/XPathContext.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/XPathContext.cs 2013-02-03 09:41:49 UTC (rev 505) +++ trunk/xmlunit/src/main/net-core/diff/XPathContext.cs 2013-02-03 10:14:36 UTC (rev 506) @@ -64,6 +64,12 @@ } } + public void AddAttribute(XmlQualifiedName attribute) { + Level current = path.Last.Value; + current.Attributes[attribute] = + new Level(ATTR + GetName(attribute)); + } + public void SetChildren<N>(IEnumerable<N> children) where N : INodeInfo { Level current = path.Last.Value; Modified: trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs 2013-02-03 09:41:49 UTC (rev 505) +++ trunk/xmlunit/src/tests/net-core/diff/DOMDifferenceEngineTest.cs 2013-02-03 10:14:36 UTC (rev 506) @@ -750,5 +750,141 @@ e2, new XPathContext())); Assert.AreEqual(1, ex.invoked); } + + [Test] + public void XsiTypesWithDifferentPrefixes() { + XmlDocument d1 = + DocumentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + XmlDocument d2 = + DocumentForString("<foo xsi:type='p2:Foo'" + + " xmlns:p2='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.DifferenceListener += ex.ComparisonPerformed; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.EQUAL, + d.CompareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + [Test] + public void XsiTypesWithDefaultNamespace() { + XmlDocument d1 = + DocumentForString("<a:foo xsi:type='Foo'" + + " xmlns='urn:xmlunit:test'" + + " xmlns:a='urn:xmlunit:test2'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + XmlDocument d2 = + DocumentForString("<a:foo xsi:type='p2:Foo'" + + " xmlns:p2='urn:xmlunit:test'" + + " xmlns:a='urn:xmlunit:test2'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.DifferenceListener += ex.ComparisonPerformed; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.EQUAL, + d.CompareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + [Test] + public void XsiTypesWithDifferentLocalNames() { + XmlDocument d1 = + DocumentForString("<foo xsi:type='p1:Bar'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + XmlDocument d2 = + DocumentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.DifferenceListener += ex.ComparisonPerformed; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.CRITICAL, + d.CompareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + [Test] + public void XsiTypesWithDifferentNamespaceURIs() { + XmlDocument d1 = + DocumentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + XmlDocument d2 = + DocumentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test2'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.DifferenceListener += ex.ComparisonPerformed; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.CRITICAL, + d.CompareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + [Test] + public void XsiTypesWithNamespaceDeclarationOnDifferentLevels() { + XmlDocument d1 = + DocumentForString("<bar xmlns:p1='urn:xmlunit:test'>" + + "<foo xsi:type='p1:Foo'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/></bar>"); + XmlDocument d2 = + DocumentForString("<bar><foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/></bar>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.DifferenceListener += ex.ComparisonPerformed; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.EQUAL, + d.CompareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + [Test] + public void XsiNil() { + XmlDocument d1 = + DocumentForString("<foo xsi:nil='true'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + XmlDocument d2 = + DocumentForString("<foo xsi:nil='false'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.DifferenceListener += ex.ComparisonPerformed; + d.DifferenceEvaluator = + DifferenceEvaluators.DefaultStopWhenDifferent; + Assert.AreEqual(ComparisonResult.CRITICAL, + d.CompareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + private XmlDocument DocumentForString(string s) { + return net.sf.xmlunit.util.Convert.ToDocument(Input.FromMemory(s).Build()); + } } } Modified: trunk/xmlunit/src/tests/net-core/diff/XPathContextTest.cs =================================================================== --- trunk/xmlunit/src/tests/net-core/diff/XPathContextTest.cs 2013-02-03 09:41:49 UTC (rev 505) +++ trunk/xmlunit/src/tests/net-core/diff/XPathContextTest.cs 2013-02-03 10:14:36 UTC (rev 506) @@ -106,6 +106,16 @@ } [Test] + public void singleAttribute() { + XPathContext ctx = new XPathContext(); + ctx.SetChildren(Linqy.Singleton(new Element("foo"))); + ctx.NavigateToChild(0); + ctx.AddAttribute(new XmlQualifiedName("bar")); + ctx.NavigateToAttribute(new XmlQualifiedName("bar")); + Assert.AreEqual("/foo[1]/@bar", ctx.XPath); + } + + [Test] public void Mixed() { List<XPathContext.INodeInfo> l = new List<XPathContext.INodeInfo>(); l.Add(new Text()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 09:41:56
|
Revision: 505 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=505&view=rev Author: bodewig Date: 2013-02-03 09:41:49 +0000 (Sun, 03 Feb 2013) Log Message: ----------- some additonal tests Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/XPathContextTest.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 08:35:12 UTC (rev 504) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 09:41:49 UTC (rev 505) @@ -665,10 +665,13 @@ } private static QName valueAsQName(Attr attribute) { + // split QName into prefix and local name String[] pieces = attribute.getValue().split(":"); if (pieces.length < 2) { + // unprefixed name pieces = new String[] { null, pieces[0] }; } else if (pieces.length > 2) { + // actually, this is not a valid QName - be lenient pieces = new String[] { pieces[0], attribute.getValue().substring(pieces[0].length() + 1) Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java 2013-02-03 08:35:12 UTC (rev 504) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/DOMDifferenceEngineTest.java 2013-02-03 09:41:49 UTC (rev 505) @@ -759,4 +759,127 @@ assertEquals(1, ex.invoked); } + @Test public void xsiTypesWithDifferentPrefixes() { + Document d1 = + documentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + Document d2 = + documentForString("<foo xsi:type='p2:Foo'" + + " xmlns:p2='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + @Test public void xsiTypesWithDefaultNamespace() { + Document d1 = + documentForString("<a:foo xsi:type='Foo'" + + " xmlns='urn:xmlunit:test'" + + " xmlns:a='urn:xmlunit:test2'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + Document d2 = + documentForString("<a:foo xsi:type='p2:Foo'" + + " xmlns:p2='urn:xmlunit:test'" + + " xmlns:a='urn:xmlunit:test2'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + @Test public void xsiTypesWithDifferentLocalNames() { + Document d1 = + documentForString("<foo xsi:type='p1:Bar'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + Document d2 = + documentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + @Test public void xsiTypesWithDifferentNamespaceURIs() { + Document d1 = + documentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + Document d2 = + documentForString("<foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test2'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + @Test public void xsiTypesWithNamespaceDeclarationOnDifferentLevels() { + Document d1 = + documentForString("<bar xmlns:p1='urn:xmlunit:test'>" + + "<foo xsi:type='p1:Foo'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/></bar>"); + Document d2 = + documentForString("<bar><foo xsi:type='p1:Foo'" + + " xmlns:p1='urn:xmlunit:test'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/></bar>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.EQUAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + @Test public void xsiNil() { + Document d1 = + documentForString("<foo xsi:nil='true'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + Document d2 = + documentForString("<foo xsi:nil='false'" + + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + + "/>"); + DOMDifferenceEngine d = new DOMDifferenceEngine(); + DiffExpecter ex = new DiffExpecter(ComparisonType.ATTR_VALUE); + d.addDifferenceListener(ex); + d.setDifferenceEvaluator(DifferenceEvaluators.DefaultStopWhenDifferent); + assertEquals(ComparisonResult.CRITICAL, + d.compareNodes(d1, new XPathContext(), + d2, new XPathContext())); + } + + private Document documentForString(String s) { + return Convert.toDocument(Input.fromMemory(s).build()); + } } Modified: trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/XPathContextTest.java =================================================================== --- trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/XPathContextTest.java 2013-02-03 08:35:12 UTC (rev 504) +++ trunk/xmlunit/src/tests/java-core/net/sf/xmlunit/diff/XPathContextTest.java 2013-02-03 09:41:49 UTC (rev 505) @@ -102,6 +102,15 @@ assertEquals("/foo[1]/@bar", ctx.getXPath()); } + @Test public void singleAttribute() { + XPathContext ctx = new XPathContext(); + ctx.setChildren(Linqy.singleton(new Element("foo"))); + ctx.navigateToChild(0); + ctx.addAttribute(new QName("bar")); + ctx.navigateToAttribute(new QName("bar")); + assertEquals("/foo[1]/@bar", ctx.getXPath()); + } + @Test public void mixed() { ArrayList<XPathContext.NodeInfo> l = new ArrayList<XPathContext.NodeInfo>(); l.add(new Text()); @@ -203,4 +212,4 @@ private static class CDATA extends NonElement { public short getType() { return Node.CDATA_SECTION_NODE; } } -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 08:35:18
|
Revision: 504 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=504&view=rev Author: bodewig Date: 2013-02-03 08:35:12 +0000 (Sun, 03 Feb 2013) Log Message: ----------- Actually, the NS lookup method is not needed when DOM3 is there Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 06:37:37 UTC (rev 503) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 08:35:12 UTC (rev 504) @@ -667,15 +667,17 @@ private static QName valueAsQName(Attr attribute) { String[] pieces = attribute.getValue().split(":"); if (pieces.length < 2) { - pieces = new String[] { "", pieces[0] }; + pieces = new String[] { null, pieces[0] }; } else if (pieces.length > 2) { pieces = new String[] { pieces[0], attribute.getValue().substring(pieces[0].length() + 1) }; } - return new QName(Nodes.findNamespaceURIForPrefix(attribute, pieces[0]), - pieces[1], pieces[0]); + if ("".equals(pieces[0])) { + pieces[0] = null; + } + return new QName(attribute.lookupNamespaceURI(pieces[0]), pieces[1]); } private static class Attributes { Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java 2013-02-03 06:37:37 UTC (rev 503) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java 2013-02-03 08:35:12 UTC (rev 504) @@ -113,35 +113,6 @@ } /** - * Looks up the namespace URI associated with a given prefix on a given node. - * @param onNode the reference node - * @param prefix the prefix to look for - * @return the URI or null of it cannot be found - */ - public static String findNamespaceURIForPrefix(Node onNode, String prefix) { - if (onNode != null && onNode instanceof Attr) { - onNode = ((Attr) onNode).getOwnerElement(); - } - while (onNode != null && onNode.getNodeType() != Node.ELEMENT_NODE) { - onNode = onNode.getParentNode(); - } - if (onNode == null) { - return null; - } - - if (prefix == null || "".equals(prefix)) { - prefix = XMLConstants.XMLNS_ATTRIBUTE; - } - Map<QName, String> attrs = getAttributes(onNode); - String uri = attrs.get(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, - prefix)); - if (uri != null) { - return uri; - } - return findNamespaceURIForPrefix(onNode.getParentNode(), prefix); - } - - /** * Trims textual content of this node, removes empty text and * CDATA children, recurses into its child nodes. * @param normalize whether to normalize whitespace as well This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-03 06:37:45
|
Revision: 503 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=503&view=rev Author: bodewig Date: 2013-02-03 06:37:37 +0000 (Sun, 03 Feb 2013) Log Message: ----------- port xsi:type special handling from 1.x branch Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/XPathContext.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java Property Changed: ---------------- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-02 14:35:56 UTC (rev 502) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 06:37:37 UTC (rev 503) @@ -328,7 +328,6 @@ testContext .addAttributes(Linqy.map(testAttributes.remainingAttributes, QNAME_MAPPER)); - Set<Attr> foundTestAttributes = new HashSet<Attr>(); lastResult = compare(new Comparison(ComparisonType.ELEMENT_NUM_ATTRIBUTES, @@ -340,6 +339,7 @@ return lastResult; } + Set<Attr> foundTestAttributes = new HashSet<Attr>(); for (Attr controlAttr : controlAttributes.remainingAttributes) { final Attr testAttr = findMatchingAttr(testAttributes.remainingAttributes, @@ -393,6 +393,12 @@ } } + lastResult = compareXsiType(controlAttributes.type, controlContext, + testAttributes.type, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + lastResult = compare(new Comparison(ComparisonType.SCHEMA_LOCATION, control, getXPath(controlContext), @@ -537,6 +543,68 @@ } /** + * Compares xsi:type attribute values + */ + private ComparisonResult compareXsiType(Attr controlAttr, + XPathContext controlContext, + Attr testAttr, + XPathContext testContext) { + boolean mustChangeControlContext = controlAttr != null; + boolean mustChangeTestContext = testAttr != null; + if (!mustChangeControlContext && !mustChangeTestContext) { + return ComparisonResult.EQUAL; + } + + try { + if (mustChangeControlContext) { + QName q = Nodes.getQName(controlAttr); + controlContext.addAttribute(q); + controlContext.navigateToAttribute(q); + } + if (mustChangeTestContext) { + QName q = Nodes.getQName(testAttr); + testContext.addAttribute(q); + testContext.navigateToAttribute(q); + } + ComparisonResult lastResult = + compare(new Comparison(ComparisonType.ATTR_NAME_LOOKUP, + controlAttr, getXPath(controlContext), + mustChangeControlContext, + testAttr, getXPath(testContext), + mustChangeTestContext)); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + if (mustChangeControlContext && mustChangeTestContext) { + lastResult = + compareAttributeExplicitness(controlAttr, controlContext, + testAttr, testContext); + if (lastResult == ComparisonResult.CRITICAL) { + return lastResult; + } + QName controlQName = valueAsQName(controlAttr); + QName testQName = valueAsQName(testAttr); + lastResult = + compare(new Comparison(ComparisonType.ATTR_VALUE, + controlAttr, + getXPath(controlContext), + controlQName.toString(), + testAttr, + getXPath(testContext), + testQName.toString())); + } + return lastResult; + } finally { + if (mustChangeControlContext) { + controlContext.navigateToParent(); + } + if (mustChangeTestContext) { + testContext.navigateToParent(); + } + } + } + + /** * Compares properties of an attribute. */ private ComparisonResult compareAttributes(Attr control, @@ -544,11 +612,8 @@ Attr test, XPathContext testContext) { ComparisonResult lastResult = - compare(new Comparison(ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED, - control, getXPath(controlContext), - control.getSpecified(), - test, getXPath(testContext), - test.getSpecified())); + compareAttributeExplicitness(control, controlContext, test, + testContext); if (lastResult == ComparisonResult.CRITICAL) { return lastResult; } @@ -561,6 +626,20 @@ } /** + * Compares whether two attributes are specified explicitly. + */ + private ComparisonResult + compareAttributeExplicitness(Attr control, XPathContext controlContext, + Attr test, XPathContext testContext) { + return + compare(new Comparison(ComparisonType.ATTR_VALUE_EXPLICITLY_SPECIFIED, + control, getXPath(controlContext), + control.getSpecified(), + test, getXPath(testContext), + test.getSpecified())); + } + + /** * Separates XML namespace related attributes from "normal" attributes.xb */ private static Attributes splitAttributes(final NamedNodeMap map) { @@ -570,28 +649,45 @@ Attr nNsLoc = (Attr) map.getNamedItemNS(XMLConstants .W3C_XML_SCHEMA_INSTANCE_NS_URI, "noNamespaceSchemaLocation"); + Attr type = (Attr) map.getNamedItemNS(XMLConstants + .W3C_XML_SCHEMA_INSTANCE_NS_URI, + "type"); List<Attr> rest = new LinkedList<Attr>(); final int len = map.getLength(); for (int i = 0; i < len; i++) { Attr a = (Attr) map.item(i); if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(a.getNamespaceURI()) - && - !XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI - .equals(a.getNamespaceURI())) { + && a != sLoc && a != nNsLoc && a != type) { rest.add(a); } } - return new Attributes(sLoc, nNsLoc, rest); + return new Attributes(sLoc, nNsLoc, type, rest); } + private static QName valueAsQName(Attr attribute) { + String[] pieces = attribute.getValue().split(":"); + if (pieces.length < 2) { + pieces = new String[] { "", pieces[0] }; + } else if (pieces.length > 2) { + pieces = new String[] { + pieces[0], + attribute.getValue().substring(pieces[0].length() + 1) + }; + } + return new QName(Nodes.findNamespaceURIForPrefix(attribute, pieces[0]), + pieces[1], pieces[0]); + } + private static class Attributes { private final Attr schemaLocation; private final Attr noNamespaceSchemaLocation; + private final Attr type; private final List<Attr> remainingAttributes; private Attributes(Attr schemaLocation, Attr noNamespaceSchemaLocation, - List<Attr> remainingAttributes) { + Attr type, List<Attr> remainingAttributes) { this.schemaLocation = schemaLocation; this.noNamespaceSchemaLocation = noNamespaceSchemaLocation; + this.type = type; this.remainingAttributes = remainingAttributes; } } Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/XPathContext.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/XPathContext.java 2013-02-02 14:35:56 UTC (rev 502) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/XPathContext.java 2013-02-03 06:37:37 UTC (rev 503) @@ -70,6 +70,12 @@ } } + public void addAttribute(QName attribute) { + Level current = path.getLast(); + current.attributes.put(attribute, + new Level(ATTR + getName(attribute))); + } + public void setChildren(Iterable<? extends NodeInfo> children) { Level current = path.getLast(); current.children.clear(); Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java 2013-02-02 14:35:56 UTC (rev 502) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java 2013-02-03 06:37:37 UTC (rev 503) @@ -113,6 +113,35 @@ } /** + * Looks up the namespace URI associated with a given prefix on a given node. + * @param onNode the reference node + * @param prefix the prefix to look for + * @return the URI or null of it cannot be found + */ + public static String findNamespaceURIForPrefix(Node onNode, String prefix) { + if (onNode != null && onNode instanceof Attr) { + onNode = ((Attr) onNode).getOwnerElement(); + } + while (onNode != null && onNode.getNodeType() != Node.ELEMENT_NODE) { + onNode = onNode.getParentNode(); + } + if (onNode == null) { + return null; + } + + if (prefix == null || "".equals(prefix)) { + prefix = XMLConstants.XMLNS_ATTRIBUTE; + } + Map<QName, String> attrs = getAttributes(onNode); + String uri = attrs.get(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, + prefix)); + if (uri != null) { + return uri; + } + return findNamespaceURIForPrefix(onNode.getParentNode(), prefix); + } + + /** * Trims textual content of this node, removes empty text and * CDATA children, recurses into its child nodes. * @param normalize whether to normalize whitespace as well Modified: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2013-02-02 14:35:56 UTC (rev 502) +++ trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2013-02-03 06:37:37 UTC (rev 503) @@ -997,7 +997,45 @@ assertTrue(diff.toString(), diff.similar()); } - public void XtestXsiTypeSpecialCaseDoesntIgnorePrefix() throws Exception { + public void testXsiTypeSpecialCaseShortLocalName() throws Exception { + String test = "<ns1:Square xsi:type=\"ns1:a\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns2:Square xsi:type=\"ns2:a\" " + + "xmlns:ns2=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void testXsiTypeSpecialCaseWorksWithDefaultNs() throws Exception { + String test = "<Square xsi:type=\"Shape\" " + + "xmlns=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns2:Square xsi:type=\"ns2:Shape\" " + + "xmlns:ns2=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void testXsiTypeSpecialCaseInheritsParentNs() throws Exception { + String test = "<ns1:Shapes xmlns:ns1=\"http://example.com/\">" + + "<ns1:Square xsi:type=\"ns1:Shape\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" + + "</ns1:Shapes>"; + + String control = "<ns2:Shapes xmlns:ns2=\"http://example.com/\">" + + "<ns2:Square xsi:type=\"ns2:Shape\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" + + "</ns2:Shapes>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void testXsiTypeSpecialCaseDoesntIgnorePrefix() throws Exception { String test = "<ns1:Square xsi:type=\"ns1:Shape\" " + "xmlns:ns1=\"http://example.com/\" " + "xmlns:ns2=\"http://example.com/another-uri/\" " Property changes on: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java ___________________________________________________________________ Modified: svn:mergeinfo - /branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java:337,346,353,494,499 /branches/xmlunit-1.x/tests/org/custommonkey/xmlunit/test_Diff.java:346 + /branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java:337,346,353,494,499,501 /branches/xmlunit-1.x/tests/org/custommonkey/xmlunit/test_Diff.java:346 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2013-02-02 14:53:45
|
Bugs item #3602981, was opened at 2013-02-01 07:05 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: David Portabella Clotet (dportabella) Assigned to: Nobody/Anonymous (nobody) Summary: Diff failswith xsi:type and different prefix Initial Comment: This code: import org.custommonkey.xmlunit.Diff; String result = "<ns1:Square xsi:type=\"ns1:Shape\" xmlns:ns1=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; String correct = "<ns2:Square xsi:type=\"ns2:Shape\" xmlns:ns2=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; Diff diff = new Diff(result, correct); System.out.println("diff:" + diff); System.out.println("diff.similar(): " + diff.similar()); results in: diff: org.custommonkey.xmlunit.Diff [not identical] Expected namespace prefix 'ns1' but was 'ns2' - comparing <ns1:Square...> at /Square[1] to <ns2:Square...> at /Square[1] [different] Expected attribute value 'ns1:Shape' but was 'ns2:Shape' - comparing <ns1:Square xsi:type="ns1:Shape"...> at /Square[1]/@type to <ns2:Square xsi:type="ns2:Shape"...> at /Square[1]/@type diff.similar(): false --- someone posted a fix here: http://stackoverflow.com/questions/14647861/xmlunit-diff-returns-similar-false-if-there-is-a-xsitype-and-a-different-namesp/14648786#14648786 ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2013-02-02 06:53 Message: This should be fixed with svn revision 502 in the 1.x Branch https://xmlunit.svn.sourceforge.net/svnroot/xmlunit/branches/xmlunit-1.x Can you try to build it yourself to see whether it works for you? Before I cut a new release I want to look around the Schema Instance namespace to see whether there is anything else XMLUnit could support in a better way. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2013-02-01 08:22 Message: Actually, XMLUnit doesn't really support much of the XML-Schema Instance stuff at all. I've started to fix it in the 1.x branch and simply ignoring the namespace prefix is trivial for this case, making sure the prefixes map to the same NS uris seems more difficult, at least as long as I'm in Java 1.4 land. Once this is fixed I'll roll a new release. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 |
From: <bo...@us...> - 2013-02-02 14:36:02
|
Revision: 502 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=502&view=rev Author: bodewig Date: 2013-02-02 14:35:56 +0000 (Sat, 02 Feb 2013) Log Message: ----------- turn xsi:type comparison into something akin to a QName comparison Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-02-02 06:52:23 UTC (rev 501) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-02-02 14:35:56 UTC (rev 502) @@ -761,10 +761,10 @@ testLocal = testValue.substring(testColon + 1); testPrefix = testValue.substring(0, testColon); } - compare(controlLocal, testLocal, control, test, listener, ATTR_VALUE); - compare(findNamespaceURIForPrefix(control, controlPrefix), - findNamespaceURIForPrefix(test, testPrefix), control, test, - listener, ATTR_VALUE); + compare("{" + findNamespaceURIForPrefix(control, controlPrefix) + "}" + + controlLocal, + "{" + findNamespaceURIForPrefix(test, testPrefix) + "}" + + testLocal, control, test, listener, ATTR_VALUE); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-02 06:52:31
|
Revision: 501 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=501&view=rev Author: bodewig Date: 2013-02-02 06:52:23 +0000 (Sat, 02 Feb 2013) Log Message: ----------- compare NS URI for xsi:type attributes. Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-02-01 16:39:16 UTC (rev 500) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-02-02 06:52:23 UTC (rev 501) @@ -752,16 +752,19 @@ String testLocal = testValue; String testPrefix = ""; int controlColon = controlValue.indexOf(":"); - if (controlColon > 0) { - controlLocal = controlValue.substring(controlColon); + if (controlColon >= 0 && controlColon < controlValue.length() - 1) { + controlLocal = controlValue.substring(controlColon + 1); controlPrefix = controlValue.substring(0, controlColon); } int testColon = testValue.indexOf(":"); - if (testColon > 0) { - testLocal = testValue.substring(testColon); + if (testColon >= 0 && testColon < testValue.length() - 1) { + testLocal = testValue.substring(testColon + 1); testPrefix = testValue.substring(0, testColon); } compare(controlLocal, testLocal, control, test, listener, ATTR_VALUE); + compare(findNamespaceURIForPrefix(control, controlPrefix), + findNamespaceURIForPrefix(test, testPrefix), control, test, + listener, ATTR_VALUE); } /** @@ -979,6 +982,34 @@ } /** + * Try to find the namespace URI that is mapped to the given + * prefix at the given node. + */ + private String findNamespaceURIForPrefix(Node onNode, String prefix) { + if (onNode != null && onNode instanceof Attr) { + onNode = ((Attr) onNode).getOwnerElement(); + } + while (onNode != null && onNode.getNodeType() != Node.ELEMENT_NODE) { + onNode = onNode.getParentNode(); + } + if (onNode == null) { + return null; + } + + NamedNodeMap attrs = onNode.getAttributes(); + Attr attr = null; + if (prefix == null || "".equals(prefix)) { + attr = (Attr) attrs.getNamedItem(XMLConstants.XMLNS_PREFIX); + } else { + attr = (Attr) attrs.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_URI, prefix); + } + if (attr != null) { + return attr.getValue(); + } + return findNamespaceURIForPrefix(onNode.getParentNode(), prefix); + } + + /** * Marker exception thrown by the protected compare() method and passed * upwards through the call stack to the public compare() method. */ Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java 2013-02-01 16:39:16 UTC (rev 500) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java 2013-02-02 06:52:23 UTC (rev 501) @@ -53,6 +53,11 @@ public static final String XMLNS_PREFIX = "xmlns"; /** + * xmlns URI + */ + public static final String XMLNS_ATTRIBUTE_URI = "http://www.w3.org/2000/xmlns/"; + + /** * "<" */ public static final String OPEN_START_NODE = "<"; Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-02-01 16:39:16 UTC (rev 500) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-02-02 06:52:23 UTC (rev 501) @@ -924,7 +924,45 @@ assertTrue(diff.toString(), diff.similar()); } - public void XtestXsiTypeSpecialCaseDoesntIgnorePrefix() throws Exception { + public void testXsiTypeSpecialCaseShortLocalName() throws Exception { + String test = "<ns1:Square xsi:type=\"ns1:a\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns2:Square xsi:type=\"ns2:a\" " + + "xmlns:ns2=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void testXsiTypeSpecialCaseWorksWithDefaultNs() throws Exception { + String test = "<Square xsi:type=\"Shape\" " + + "xmlns=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns2:Square xsi:type=\"ns2:Shape\" " + + "xmlns:ns2=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void testXsiTypeSpecialCaseInheritsParentNs() throws Exception { + String test = "<ns1:Shapes xmlns:ns1=\"http://example.com/\">" + + "<ns1:Square xsi:type=\"ns1:Shape\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" + + "</ns1:Shapes>"; + + String control = "<ns2:Shapes xmlns:ns2=\"http://example.com/\">" + + "<ns2:Square xsi:type=\"ns2:Shape\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" + + "</ns2:Shapes>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void testXsiTypeSpecialCaseDoesntIgnorePrefix() throws Exception { String test = "<ns1:Square xsi:type=\"ns1:Shape\" " + "xmlns:ns1=\"http://example.com/\" " + "xmlns:ns2=\"http://example.com/another-uri/\" " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-01 16:39:23
|
Revision: 500 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=500&view=rev Author: bodewig Date: 2013-02-01 16:39:16 +0000 (Fri, 01 Feb 2013) Log Message: ----------- 3602981 doesn't affect the 2.x code base - at least in Java - as the xsi:type attributes are ignored completely. Not good either Modified Paths: -------------- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java Property Changed: ---------------- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java Modified: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2013-02-01 16:30:03 UTC (rev 499) +++ trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java 2013-02-01 16:39:16 UTC (rev 500) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2008,2010 Jeff Martin, Tim Bacon +Copyright (c) 2001-2013, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -981,5 +981,35 @@ diff = new Diff(test, control); assertTrue(diff.toString(), diff.identical()); } + + /** + * @see http://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 + */ + public void testXsiTypeSpecialCase() throws Exception { + String test = "<ns1:Square xsi:type=\"ns1:Shape\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns2:Square xsi:type=\"ns2:Shape\" " + + "xmlns:ns2=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void XtestXsiTypeSpecialCaseDoesntIgnorePrefix() throws Exception { + String test = "<ns1:Square xsi:type=\"ns1:Shape\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:ns2=\"http://example.com/another-uri/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns1:Square xsi:type=\"ns2:Shape\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:ns2=\"http://example.com/another-uri/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertFalse(diff.toString(), diff.similar()); + } + } Property changes on: trunk/xmlunit/src/tests/java-legacy/org/custommonkey/xmlunit/test_Diff.java ___________________________________________________________________ Added: svn:mergeinfo + /branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java:337,346,353,494,499 /branches/xmlunit-1.x/tests/org/custommonkey/xmlunit/test_Diff.java:346 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2013-02-01 16:30:10
|
Revision: 499 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=499&view=rev Author: bodewig Date: 2013-02-01 16:30:03 +0000 (Fri, 01 Feb 2013) Log Message: ----------- partial fix for comparison of XSI type attribute values. See Bug 3602981 Modified Paths: -------------- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java Property Changed: ---------------- branches/xmlunit-1.x/ Property changes on: branches/xmlunit-1.x ___________________________________________________________________ Added: svn:ignore + build Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2011-11-02 07:59:58 UTC (rev 498) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2013-02-01 16:30:03 UTC (rev 499) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2009, Jeff Martin, Tim Bacon +Copyright (c) 2001-2013, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -704,6 +704,18 @@ } /** + * @param attr + * @return true if the attribute is an XML Schema Instance + * namespace attribute XMLUnit treats in a special way. + */ + private boolean isXMLSchemaTypeAttribute(Attr attr) { + return XMLConstants + .W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(attr.getNamespaceURI()) + && XMLConstants.W3C_XML_SCHEMA_INSTANCE_TYPE_ATTR + .equals(attr.getLocalName()); + } + + /** * Compare two attributes * @param control * @param test @@ -717,15 +729,41 @@ compare(control.getPrefix(), test.getPrefix(), control, test, listener, NAMESPACE_PREFIX); - - compare(control.getValue(), test.getValue(), control, test, - listener, ATTR_VALUE); - + if (isXMLSchemaTypeAttribute(control) + && isXMLSchemaTypeAttribute(test)) { + compareXMLSchemaTypeAttributeValues(control, test, listener); + } else { + compare(control.getValue(), test.getValue(), control, test, + listener, ATTR_VALUE); + } compare(control.getSpecified() ? Boolean.TRUE : Boolean.FALSE, test.getSpecified() ? Boolean.TRUE : Boolean.FALSE, control, test, listener, ATTR_VALUE_EXPLICITLY_SPECIFIED); } + private void compareXMLSchemaTypeAttributeValues(Attr control, Attr test, + DifferenceListener listener) + throws DifferenceFoundException { + String controlValue = control.getValue(); + String testValue = test.getValue(); + + String controlLocal = controlValue; + String controlPrefix = ""; + String testLocal = testValue; + String testPrefix = ""; + int controlColon = controlValue.indexOf(":"); + if (controlColon > 0) { + controlLocal = controlValue.substring(controlColon); + controlPrefix = controlValue.substring(0, controlColon); + } + int testColon = testValue.indexOf(":"); + if (testColon > 0) { + testLocal = testValue.substring(testColon); + testPrefix = testValue.substring(0, testColon); + } + compare(controlLocal, testLocal, control, test, listener, ATTR_VALUE); + } + /** * Compare two CDATA sections - unused, kept for backwards compatibility * @param control Modified: branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java =================================================================== --- branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java 2011-11-02 07:59:58 UTC (rev 498) +++ branches/xmlunit-1.x/src/java/org/custommonkey/xmlunit/XMLConstants.java 2013-02-01 16:30:03 UTC (rev 499) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2007 Jeff Martin, Tim Bacon +Copyright (c) 2001-2013 Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -157,4 +157,10 @@ */ String W3C_XML_SCHEMA_INSTANCE_NO_NAMESPACE_SCHEMA_LOCATION_ATTR = "noNamespaceSchemaLocation"; + + /** + * "type" + */ + public static final String W3C_XML_SCHEMA_INSTANCE_TYPE_ATTR + = "type"; } Modified: branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java =================================================================== --- branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2011-11-02 07:59:58 UTC (rev 498) +++ branches/xmlunit-1.x/tests/java/org/custommonkey/xmlunit/test_Diff.java 2013-02-01 16:30:03 UTC (rev 499) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001-2008, Jeff Martin, Tim Bacon +Copyright (c) 2001-2013, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -908,5 +908,34 @@ ElementNameAndAttributeQualifier()); assertTrue(diff.toString(), diff.similar()); } + + /** + * @see http://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 + */ + public void testXsiTypeSpecialCase() throws Exception { + String test = "<ns1:Square xsi:type=\"ns1:Shape\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns2:Square xsi:type=\"ns2:Shape\" " + + "xmlns:ns2=\"http://example.com/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertTrue(diff.toString(), diff.similar()); + } + + public void XtestXsiTypeSpecialCaseDoesntIgnorePrefix() throws Exception { + String test = "<ns1:Square xsi:type=\"ns1:Shape\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:ns2=\"http://example.com/another-uri/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + + String control = "<ns1:Square xsi:type=\"ns2:Shape\" " + + "xmlns:ns1=\"http://example.com/\" " + + "xmlns:ns2=\"http://example.com/another-uri/\" " + + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; + Diff diff = new Diff(control, test); + assertFalse(diff.toString(), diff.similar()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: SourceForge.net <no...@so...> - 2013-02-01 16:22:24
|
Bugs item #3602981, was opened at 2013-02-01 07:05 Message generated for change (Comment added) made by bodewig You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: David Portabella Clotet (dportabella) Assigned to: Nobody/Anonymous (nobody) Summary: Diff failswith xsi:type and different prefix Initial Comment: This code: import org.custommonkey.xmlunit.Diff; String result = "<ns1:Square xsi:type=\"ns1:Shape\" xmlns:ns1=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; String correct = "<ns2:Square xsi:type=\"ns2:Shape\" xmlns:ns2=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; Diff diff = new Diff(result, correct); System.out.println("diff:" + diff); System.out.println("diff.similar(): " + diff.similar()); results in: diff: org.custommonkey.xmlunit.Diff [not identical] Expected namespace prefix 'ns1' but was 'ns2' - comparing <ns1:Square...> at /Square[1] to <ns2:Square...> at /Square[1] [different] Expected attribute value 'ns1:Shape' but was 'ns2:Shape' - comparing <ns1:Square xsi:type="ns1:Shape"...> at /Square[1]/@type to <ns2:Square xsi:type="ns2:Shape"...> at /Square[1]/@type diff.similar(): false --- someone posted a fix here: http://stackoverflow.com/questions/14647861/xmlunit-diff-returns-similar-false-if-there-is-a-xsitype-and-a-different-namesp/14648786#14648786 ---------------------------------------------------------------------- >Comment By: Stefan Bodewig (bodewig) Date: 2013-02-01 08:22 Message: Actually, XMLUnit doesn't really support much of the XML-Schema Instance stuff at all. I've started to fix it in the 1.x branch and simply ignoring the namespace prefix is trivial for this case, making sure the prefixes map to the same NS uris seems more difficult, at least as long as I'm in Java 1.4 land. Once this is fixed I'll roll a new release. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 |
From: SourceForge.net <no...@so...> - 2013-02-01 15:05:24
|
Bugs item #3602981, was opened at 2013-02-01 07:05 Message generated for change (Tracker Item Submitted) made by dportabella You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: David Portabella Clotet (dportabella) Assigned to: Nobody/Anonymous (nobody) Summary: Diff failswith xsi:type and different prefix Initial Comment: This code: import org.custommonkey.xmlunit.Diff; String result = "<ns1:Square xsi:type=\"ns1:Shape\" xmlns:ns1=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; String correct = "<ns2:Square xsi:type=\"ns2:Shape\" xmlns:ns2=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"; Diff diff = new Diff(result, correct); System.out.println("diff:" + diff); System.out.println("diff.similar(): " + diff.similar()); results in: diff: org.custommonkey.xmlunit.Diff [not identical] Expected namespace prefix 'ns1' but was 'ns2' - comparing <ns1:Square...> at /Square[1] to <ns2:Square...> at /Square[1] [different] Expected attribute value 'ns1:Shape' but was 'ns2:Shape' - comparing <ns1:Square xsi:type="ns1:Shape"...> at /Square[1]/@type to <ns2:Square xsi:type="ns2:Shape"...> at /Square[1]/@type diff.similar(): false --- someone posted a fix here: http://stackoverflow.com/questions/14647861/xmlunit-diff-returns-similar-false-if-there-is-a-xsitype-and-a-different-namesp/14648786#14648786 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3602981&group_id=23187 |