xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r695482 - /xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp
Date Mon, 15 Sep 2008 14:23:32 GMT
Author: amassari
Date: Mon Sep 15 07:23:31 2008
New Revision: 695482

URL: http://svn.apache.org/viewvc?rev=695482&view=rev
Log:
Print the list of facets in alphabetical order, so that the list is stable also on 64 bit
machines

Modified:
    xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp

Modified: xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp?rev=695482&r1=695481&r2=695482&view=diff
==============================================================================
--- xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp (original)
+++ xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp Mon Sep 15 07:23:31 2008
@@ -431,20 +431,35 @@
 
     // Facets
 	RefHashTableOf<KVStringPair>* facets = dtValidator->getFacets();
-    if( facets )
+    if( facets && facets->getCount()>0)
     {
+        XMLSize_t i;
+        // Element's properties
+        XERCES_STD_QUALIFIER cout << "Facets:\t\t\n";
+        // use a list to print them sorted, or the list could be different on 64-bit machines
+        RefVectorOf<const XMLCh> sortedList(facets->getCount(), false);
         RefHashTableOfEnumerator<KVStringPair> enumFacets(facets);
-        if( enumFacets.hasMoreElements() )
+        while( enumFacets.hasMoreElements() )
         {
-            XERCES_STD_QUALIFIER cout << "Facets:\t\t\n";
+            const KVStringPair& curPair = enumFacets.nextElement();
+            const XMLCh* key=curPair.getKey();
+            XMLSize_t len=sortedList.size();
+            for(i=0;i<len;i++)
+                if(XMLString::compareString(key, sortedList.elementAt(i))<0)
+                {
+                    sortedList.insertElementAt(key,i);
+                    break;
+                }
+            if(i==len)
+                sortedList.addElement(key);
         }
 
-        while(enumFacets.hasMoreElements())
+        XMLSize_t len=sortedList.size();
+        for(i=0;i<len;i++)
         {
-            // Element's properties
-            const KVStringPair& curPair = enumFacets.nextElement();
-            XERCES_STD_QUALIFIER cout << "\t" << StrX( curPair.getKey() )   
<< "="
-                         << StrX( curPair.getValue() )  << "\n";
+            const XMLCh* key = sortedList.elementAt(i);
+            XERCES_STD_QUALIFIER cout << "\t" << StrX( key )    << "="
+                         << StrX( facets->get(key)->getValue() )  << "\n";
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org


Mime
View raw message