src/XPathHandler.h
branchv_0
changeset 3 709abeb5f6d1
parent 2 426054465916
child 4 c58c7f2d4785
--- a/src/XPathHandler.h	Wed Dec 30 01:28:45 2020 +0100
+++ b/src/XPathHandler.h	Wed Dec 30 01:37:41 2020 +0100
@@ -49,6 +49,7 @@
 	std::vector<relpipe::reader::handlers::AttributeMetadata> currentReaderMetadata;
 	std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata;
 	size_t currentAttributeIndex = 0;
+	size_t currentRecordNumber = 1;
 
 
 	xmlpp::DomParser dom;
@@ -117,6 +118,8 @@
 
 		currentReaderMetadata = attributes;
 		currentWriterMetadata.clear();
+		currentRecordNumber = 1;
+		recordElement = nullptr;
 
 		if (currentRelationConfiguration == nullptr) {
 			copyInputAttributesToOutput();
@@ -142,6 +145,10 @@
 			attributeElement->set_attribute("type", s2x(attributeMetadata.getTypeName()));
 			attributeElement->add_child_text(s2x(value));
 
+			if (currentAttributeIndex == 0) {
+				recordElement->set_attribute("number", std::to_string(currentRecordNumber));
+			}
+
 			currentAttributeIndex++;
 
 			if (currentAttributeIndex == currentReaderMetadata.size()) {
@@ -153,6 +160,7 @@
 
 				resetRecordElement();
 				currentAttributeIndex = 0;
+				currentRecordNumber++;
 			}
 		} else {
 			relationalWriter->writeAttribute(value);