You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Andreas Hartmann <an...@apache.org> on 2005/02/28 10:24:23 UTC

Re: svn commit: r155652 - in lenya/trunk/src: java/org/apache/lenya/cms/site/usecases/Assets.java java/org/apache/lenya/cms/site/usecases/SiteUsecase.java webapp/lenya/usecases/tab/assets.jx

gregor@apache.org wrote:

> +                    title = metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", "title").item(0
 > .getChildNodes().item(0).getNodeValue();

This might be critical. In some cases, XML documents can look like

   <hello>foo bar</hello>

   - element node <hello>
     - text node "foo"
     - text node " "
     - text node "bar"


This will probably not happen when you read the plain file, but
it can happen e.g. after an XSL transformation:


    <hello>
      <xsl:text>foo</xsl:text>
      <xsl:text> </xsl:text>
      <xsl:text>bar</xsl:text>

Before normalizing the document, it contains 3 subsequent text nodes.
In this case, .getChildNodes().item(0).getNodeValue(); will return "foo"
instead of "foo bar".

You can always use DocumentHelper.getSimpleElementText() safely.

-- Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org