You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2008/09/15 16:23:32 UTC

svn commit: r695482 - /xerces/c/trunk/samples/src/SEnumVal/SEnumVal.cpp

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