DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14472>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14472 MORE truncation error in XPathAPI.selectSingleNode() Summary: MORE truncation error in XPathAPI.selectSingleNode() Product: XalanJ2 Version: 2.4 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: org.apache.xpath AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I reported this bug (?) earlier, but would like to provide some more info now to help you reproduce it. I reported it earlier as a truncation error in the XPathAPI.selectSingleNode method. The error occurs when the following document is transformed by the following stylesheet into a DOMResult, and then the DOMResult is processed using XPathAPI. *PLEASE* let me know if you can recreate this error, and, if so, whether there is a workaround. Thanks. THE DOCUMENT: <?xml version="1.0" encoding="UTF-8"?> <clinical_document> <Questionnaire> <CodedConcept> <ConceptUUID>60</ConceptUUID> </CodedConcept> </Questionnaire> <patient>08f1420b-0ae8-4ee7-8a6e-904fd584898b</patient> <observations>12345</observations> </clinical_document> THE STYLESHEET: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lxslt="http://xml.apache.org/xslt" version="1.0"> <xsl:output method="xml" /> <!-- Global parameters needed in each relational row --> <!-- PatientUUID --> <xsl:param name="PatientUUID"> <xsl:value-of select="/clinical_document/patient"/> </xsl:param> <!-- Top-level element --> <xsl:template match="clinical_document"> <DBLoader> <Database> <xsl:text>Inoveon_AnDS</xsl:text> </Database> <xsl:apply-templates select="observations"/> </DBLoader> </xsl:template> <xsl:template match="observations"> <Table> <TableName>DemoFindings</TableName> <Field> <FieldName>PatientUUID</FieldName> <FieldValue><xsl:value-of select="$PatientUUID"/></FieldValue> </Field> </Table> </xsl:template> </xsl:stylesheet> THE PROBLEM: After transformation, the resulting DOMResult instance is passed to a process that tries to extract the text value of the PatientUUID, i.e. it extracts the FieldValue text of the Field Node for which the FieldName text = "PatientUUID". This is done via the following XPathAPI calls: 1. XPathAPI.selectNodeList(xmlDoc,"//DBLoader/Table"); //get list of Table nodes (only one returned in this case. It is passed to the next method) 2. XPathAPI.selectNodeList(tableNode,"Field"); //get list of Field nodes (only one returned in this case also. It is passed to the next method). (I've included the full listing of the method that extracts the field name, so you can see where the 'printSerialized' debug output is generated) 3. public static String getFieldValue(Node fieldNode) throws XMLDataAccessorException { Node tempParentNode = null; Node tempChildNode = null; String fieldValue = ""; //Print entire Node printSerialized(fieldNode); System.out.println("\n"); try { //Use XPathAPI call to extract the appropriate node, using an XPath expression tempParentNode = XPathAPI.selectSingleNode(fieldNode,"FieldValue"); //Print <Field> Node printSerialized(tempParentNode); System.out.println("\n"); //Some error checking if (tempParentNode == null) throw new XMLDataAccessorException("XMLDataAccessorException in extracting Field value from DBLoader Field Element: Field Element is missing FieldValue Element"); else { tempChildNode = XPathAPI.selectSingleNode(tempParentNode,"text()"); if (tempChildNode == null) fieldValue = ""; //if there's no text() node, the value is the empty string for our purposes (this is not an Exception) else fieldValue = tempChildNode.getNodeValue(); //Print <FieldValue> Node printSerialized(tempChildNode); System.out.println("\n"); } } catch (TransformerException te) { throw new XMLDataAccessorException("XMLDataAccessorException in extracting Field value from DBLoader Field Element: TransformerException: " + te.getMessage());} // If all is well, return the value return fieldValue; } Now, when this method runs, the fieldValue string that is returned is a *truncated* version of the string in the original xml document. However, the debug information that's printed out indicates that the full string is, indeed, in the field Node, but gets truncated by the second call to XPathAPI.selectSingleNode(): <?xml version="1.0" encoding="UTF-8" standalone="no"?><Field><FieldName>PatientUUID</FieldName><FieldValue>08f1420b- 0ae8-4ee7-8a6e-904fd584898b</FieldValue ></Field> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <FieldValue>08f1420b-0ae8-4ee7-8a6e-904fd584898b</FieldValue> <?xml version="1.0" encoding="UTF-8" standalone="no"?> 08f1420b-0ae8-4ee7-8a6e-90 Obviously, the value to be extracted has been truncated after the second call to XPathAPI.selectSingleNode().
