[ 
http://issues.apache.org/jira/browse/XALANJ-2265?page=comments#action_12373202 
] 

Brian Minchau commented on XALANJ-2265:
---------------------------------------

Comments from Xalan-J triage April 4, 2006:
> Henry Z. will check if this is a valid bug. There are issues
> with text nodes with zero characters.

> Creating in-memory DocumentFragment with imbedded null text elements causes 
> Trax NPE
> ------------------------------------------------------------------------------------
>
>          Key: XALANJ-2265
>          URL: http://issues.apache.org/jira/browse/XALANJ-2265
>      Project: XalanJ2
>         Type: Bug

>   Components: XSLTC
>     Versions: 2.7
>  Environment: cygwin under XP, java 1.4.2_09
>     Reporter: Travis Winfrey

>
> The trax library cannot handle the null text element, when a DocumentFragment 
> is created that has some null text nodes.  In contrast, other XSLTC libraries 
> treat the middleName=null variation shown below as  <MiddleName/>
> Example code to create DocumentFragment with null text element
>     import org.w3c.dom.Document;
>     import org.w3c.dom.DocumentFragment;
>     import org.w3c.dom.Element;
>     public DocumentFragment createDocFragment(Document doc) throws 
> ParserConfigurationException, NullPointerException {
>         DocumentFragment docFrag = doc.createDocumentFragment();
>         Element person = doc.createElement("Person");
>         String firstName = "George";
>         String middleName = "";
>         String lastName = "Washington";
>         if (this.isMiddleNameNull) {
>             middleName = null;
>         }
>         
> person.appendChild(doc.createElement("FirstName")).appendChild(doc.createTextNode(firstName));
>         
> person.appendChild(doc.createElement("MiddleName")).appendChild(doc.createTextNode(middleName));
>         
> person.appendChild(doc.createElement("LastName")).appendChild(doc.createTextNode(lastName));
>         docFrag.appendChild(person);
>         return docFrag;
>     }
> Sample xsl code to tickle bug.     any of these will work .
>    <xsl:value-of select="/Person/MiddleName" />
>    <xsl:value-of select="." />
>    <xsl:value-of select="./*" />
> One cause of the NPE is org.apache.xalan.xsltc.trax.DOM2SAX.parse routine 
> looks like this:
>      private void parse(Node node) throws IOException, SAXException {
>       // .. tlw omit 5 lines ...
>         switch (node.getNodeType()) {
>       // ... tlw omit 131 lines ...
>         case Node.TEXT_NODE:
>             final String data = node.getNodeValue();                          
>  
>             _sax.characters(data.toCharArray(), 0, data.length());    // tlw: 
> kaboom
>             break;
>         }
>     }
> This is $Id: DOM2SAX.java,v 1.21 2004/02/16 22:57:21 minchau Exp $

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to