You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by COCHET Jérôme FTRD/DIH/REN <je...@rd.francetelecom.fr> on 2001/04/26 16:07:47 UTC

pb entities resolution

Hi,

here is sample.xml :
------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>

<!DOCTYPE DOC [
<!ELEMENT DOC (ELT)>
<!ELEMENT ELT (#PCDATA)>
<!ENTITY STR_a_name   "John">
]>

<DOC>
	<ELT>Hello &STR_a_name;</ELT>
</DOC>
-------------------------------------------------------------

I use this code to create the "sample.xml" Document object (xml_doc) :

	DocumentBuilderFactory dFactory =
DocumentBuilderFactory.newInstance();                                
	dFactory.setExpandEntityReferences(true);
	dFactory.setValidating(false);
	DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
	try
	{
	xml_doc = dBuilder.parse("sample.xml");
	}
	catch(org.xml.sax.SAXParseException E)
	{
	System.out.println(E); 
	}

The problem is that when I get back the "ELT" text node, I obtain "Hello "
instead of "Hello John".
Any idea ?


thanks in advance

Re: pb entities resolution

Posted by James Melton <ja...@cylogix.com>.
A beginning FAQ (just reposted to the list) includes this item:

Q: How come my [DTD doesn't get validated|my &entities; aren't
resolved]?
A: You probably want the xerces-j-dev list, not the xalan-dev list,
since
these kinds of issues are most often with the XML parser, and not the
XSLT
processor.  Many aspects of reading in XML files for use are handled in
the
parser, and Xalan doesn't even know about them.


COCHET Jérôme FTRD/DIH/REN wrote:
> 
> Hi,
> 
> here is sample.xml :
> ------------------------------------------------------------
> <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
> 
> <!DOCTYPE DOC [
> <!ELEMENT DOC (ELT)>
> <!ELEMENT ELT (#PCDATA)>
> <!ENTITY STR_a_name   "John">
> ]>
> 
> <DOC>
>         <ELT>Hello &STR_a_name;</ELT>
> </DOC>
> -------------------------------------------------------------
> 
> I use this code to create the "sample.xml" Document object (xml_doc) :
> 
>         DocumentBuilderFactory dFactory =
> DocumentBuilderFactory.newInstance();
>         dFactory.setExpandEntityReferences(true);
>         dFactory.setValidating(false);
>         DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
>         try
>         {
>         xml_doc = dBuilder.parse("sample.xml");
>         }
>         catch(org.xml.sax.SAXParseException E)
>         {
>         System.out.println(E);
>         }
> 
> The problem is that when I get back the "ELT" text node, I obtain "Hello "
> instead of "Hello John".
> Any idea ?
> 
> thanks in advance

-- 

____________________________________________________________
James Melton                 CyLogix
609.750.5190                 609.750.5100
james.melton@cylogix.com     www.cylogix.com