Revision 1415
Added by Jing Tao almost 22 years ago
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
79 | 79 |
|
80 | 80 |
protected static final int MAXDATACHARS = 4000; |
81 | 81 |
protected static final long INDEXDELAY = 10000; |
82 |
// methods writeChildNodeToDB, setAttribute, setNamespace, |
|
83 |
// writeTextForDBSAXNode will increase endNodeId. |
|
84 |
protected long endNodeId = -1; // The end node id for a substree |
|
82 | 85 |
// DOCTITLE attr cleared from the db |
83 | 86 |
// private static final int MAXTITLELEN = 1000; |
84 | 87 |
|
... | ... | |
214 | 217 |
if (hitTextNode && parentNode != null) |
215 | 218 |
{ |
216 | 219 |
// write the textbuffer into db for parent node. |
217 |
writeTextForDBSAXNode(textBuffer, parentNode); |
|
220 |
endNodeId = writeTextForDBSAXNode(textBuffer, parentNode);
|
|
218 | 221 |
// rest hitTextNode |
219 | 222 |
hitTextNode =false; |
220 | 223 |
// reset textbuffer |
... | ... | |
324 | 327 |
{ |
325 | 328 |
String attributeName = atts.getQName(i); |
326 | 329 |
String attributeValue = atts.getValue(i); |
327 |
currentNode.setAttribute(attributeName, attributeValue, docid); |
|
330 |
endNodeId = |
|
331 |
currentNode.setAttribute(attributeName, attributeValue, docid); |
|
328 | 332 |
|
329 | 333 |
// To handle name space and schema location if the attribute name is |
330 | 334 |
// xsi:schemaLocation. If the name space is in not in catalog table |
... | ... | |
511 | 515 |
} |
512 | 516 |
|
513 | 517 |
// Write the content of the node to the database |
514 |
currentNode.writeChildNodeToDB("TEXT", null, data, docid); |
|
518 |
endNodeId = currentNode.writeChildNodeToDB("TEXT", null, data, docid);
|
|
515 | 519 |
} |
516 | 520 |
} |
517 | 521 |
|
... | ... | |
523 | 527 |
throws SAXException { |
524 | 528 |
MetaCatUtil.debugMessage("PI", 50); |
525 | 529 |
DBSAXNode currentNode = (DBSAXNode)nodeStack.peek(); |
526 |
currentNode.writeChildNodeToDB("PI", target, data, docid); |
|
530 |
endNodeId = currentNode.writeChildNodeToDB("PI", target, data, docid);
|
|
527 | 531 |
} |
528 | 532 |
|
529 | 533 |
/** SAX Handler that is called at the end of each XML element */ |
... | ... | |
540 | 544 |
if (hitTextNode) |
541 | 545 |
{ |
542 | 546 |
MetaCatUtil.debugMessage("Write text into DB in End Element", 50); |
543 |
writeTextForDBSAXNode(textBuffer, currentNode); |
|
547 |
endNodeId = writeTextForDBSAXNode(textBuffer, currentNode);
|
|
544 | 548 |
}//if |
545 | 549 |
|
546 | 550 |
//set hitText false |
... | ... | |
590 | 594 |
MetaCatUtil.debugMessage("COMMENT", 50); |
591 | 595 |
if ( !processingDTD ) { |
592 | 596 |
DBSAXNode currentNode = (DBSAXNode)nodeStack.peek(); |
593 |
currentNode.writeChildNodeToDB("COMMENT", null, new String(ch), docid); |
|
597 |
endNodeId = |
|
598 |
currentNode.writeChildNodeToDB("COMMENT", null, new String(ch), docid); |
|
594 | 599 |
} |
595 | 600 |
} |
596 | 601 |
|
... | ... | |
725 | 730 |
} |
726 | 731 |
|
727 | 732 |
/* Method to write a text buffer for DBSAXNode*/ |
728 |
protected void writeTextForDBSAXNode(StringBuffer strBuffer, DBSAXNode node)
|
|
733 |
protected long writeTextForDBSAXNode(StringBuffer strBuffer, DBSAXNode node)
|
|
729 | 734 |
throws SAXException |
730 | 735 |
{ |
736 |
long nodeId = -1; |
|
731 | 737 |
// Check parameter |
732 | 738 |
if ( strBuffer == null || node == null) |
733 | 739 |
{ |
734 |
return; |
|
740 |
return nodeId;
|
|
735 | 741 |
} |
736 | 742 |
boolean moredata = true; |
737 | 743 |
String data = null; |
... | ... | |
763 | 769 |
} |
764 | 770 |
|
765 | 771 |
// Write the content of the node to the database |
766 |
node.writeChildNodeToDB("TEXT", null, data, docid); |
|
772 |
nodeId = node.writeChildNodeToDB("TEXT", null, data, docid);
|
|
767 | 773 |
}//while |
768 | 774 |
}//if |
775 |
return nodeId; |
|
769 | 776 |
} |
770 | 777 |
} |
Also available in: Unified diff
Add a varible to keep track node id and every call for write to xml_nodes will return a node id.