Parcourir la source

XML Attributes from nested records without tag name belong to parent
Also moved call to gather attributes to DataSourceMetaData constructor.

Signed-off-by: Anthony Fishbeck <Anthony.Fishbeck@lexisnexis.com>

Anthony Fishbeck il y a 13 ans
Parent
commit
f476c3a88f
2 fichiers modifiés avec 7 ajouts et 10 suppressions
  1. 7 9
      common/fileview2/fvsource.cpp
  2. 0 1
      common/fileview2/fvsource.ipp

+ 7 - 9
common/fileview2/fvsource.cpp

@@ -172,6 +172,7 @@ DataSourceMetaData::DataSourceMetaData(IHqlExpression * _record, byte _numFields
         addSimpleField("__groupfollows__", NULL, type);
         maxRecordSize++;
     }
+    gatherAttributes();
 
     if (isStoredFixedWidth)
         assertex(storedFixedSize == maxRecordSize);
@@ -207,12 +208,10 @@ void DataSourceMetaData::init()
     isStoredFixedWidth = false;
     randomIsOk = false;
     numFieldsToIgnore = 0;
-    gatheredAttributes = false;
 }
 
 DataSourceMetaData::DataSourceMetaData(MemoryBuffer & buffer)
 {
-    gatheredAttributes = false;
     numVirtualFields = 0;
     buffer.read(numFieldsToIgnore);
     buffer.read(randomIsOk);
@@ -236,6 +235,7 @@ DataSourceMetaData::DataSourceMetaData(MemoryBuffer & buffer)
         if (flags == FVFFvirtual)
             ++numVirtualFields;
     }
+    gatherAttributes();
 }
 
 
@@ -460,7 +460,7 @@ void DataSourceMetaData::gatherNestedAttributes(DataSourceMetaItem &rec, aindex_
         if (item.flags==FVFFendrecord)
             return;
         else if (item.flags==FVFFbeginrecord)
-            gatherNestedAttributes(item, idx);
+            gatherNestedAttributes((!item.tagname.get() || *item.tagname.get()) ? item : rec, idx);
         else if (item.isXmlAttribute())
             rec.nestedAttributes.append(idx);
     }
@@ -473,24 +473,22 @@ void DataSourceMetaData::gatherAttributes()
     {
         DataSourceMetaItem &item = fields.item(idx);
         if (item.flags==FVFFbeginrecord)
-            gatherNestedAttributes(item, idx);
+        {
+            if (!item.tagname.get() || *item.tagname.get())
+                gatherNestedAttributes(item, idx);
+        }
         else if (item.isXmlAttribute())
             attributes.append(idx);
     }
-    gatheredAttributes=true;
 }
 
 const IntArray &DataSourceMetaData::queryAttrList(unsigned column)
 {
-    if (!gatheredAttributes)
-        gatherAttributes();
     return fields.item(column).nestedAttributes;
 }
 
 const IntArray &DataSourceMetaData::queryAttrList()
 {
-    if (!gatheredAttributes)
-        gatherAttributes();
     return attributes;
 }
 

+ 0 - 1
common/fileview2/fvsource.ipp

@@ -152,7 +152,6 @@ protected:
     bool isStoredFixedWidth;
     bool randomIsOk;
     byte numFieldsToIgnore;
-    bool gatheredAttributes;
     StringAttr tagname;
 };