Scott:
  I took a closer look at what the parser is doing when the entity is external 
vs. inline, and the difference is an
extra call to the "characters" method of the DocumentHandler when  there is 
white space at the beginning of the
entity.  So the parse would look like this when everything works normally:

startElement (page)
characters  (whitespace before &values;)
startElement (foo)

And when things are not working, the parse looks like this:

startElement(page)
characters (whitespace before &values;)
characters (whitespace at beginning of external entity)
startElement (foo)


Hope this helps.
Chris


"Chris P. McCabe" wrote:

> Further testing showed that any whitespace character at the beginning of the 
> external entity causes the problem.
> Not just a newline.  A single space will do it.
>
> Chris
>
> Scott Boag/CAM/Lotus wrote:
>
> > Wow, I don't know what's going on then.
> >
> > Xerces folks, any idea what I could be doing in my parser derivative to
> > cause this?  I can't see what I would be doing that would change behavior
> > based on if there's a newline in the beginning of the external entity.
> >
> > -scott
> >
> >
> >                     "Chris P. McCabe"
> >                     <[EMAIL PROTECTED]        To:     
> > xalan-dev@xml.apache.org
> >                     otels.com>                   cc:     [EMAIL PROTECTED], 
> > (bcc: Scott Boag/CAM/Lotus)
> >                     Sent by:                     Subject:     Re: Bug: 
> > External Entities that begin with newline
> >                     [EMAIL PROTECTED]
> >                     com
> >
> >
> >                     01/24/00 01:30 PM
> >                     Please respond to
> >                     xerces-dev
> >
> >
> >
> > I tried parsing this with just Xerces, and it seems to handle it fine.  In
> > both cases it reads and parses the
> > external entity properly.  I expected this to be the case since Xalan
> > properly processes the XML in the
> > external entity when it is referenced in a different manner than in this
> > test case.
> >
> > Chris
> >
> > Scott Boag/CAM/Lotus wrote:
> >
> > > Interesting.  My first bet is that this is a Xerces issue.  You should
> > try
> > > the parse with just Xerces to see what happens.
> > >
> > > -scott
> > >
> > >
> > >                     "Chris P. McCabe"
> > >                     <[EMAIL PROTECTED]        To:
> > xalan-dev@xml.apache.org
> > >                     otels.com>                   cc:     (bcc: Scott
> > Boag/CAM/Lotus)
> > >                     Sent by:                     Subject:     Bug:
> > External Entities that begin with newline
> > >                     [EMAIL PROTECTED]
> > >                     com
> > >
> > >
> > >                     01/21/00 05:37 PM
> > >                     Please respond to
> > >                     xalan-dev
> > >
> > >
> > >
> > > I don't know if this is a Xerces or Xalan bug, but if an external entity
> > > that contains XML begins with a newline character, the XML cannot be
> > > referenced in the stylesheet in certain circumstances.  In the test case
> > > below, if test2.xml begins with a newline, the xsl:value-of element in
> > > the stylesheet will produce no value.  If the newline is removed, it
> > > works as expected.  This is a contrived example to illustrate the
> > > problem, and if a template is created for the "bar" element and
> > > apply-templates is called, it works correctly in either case.
> > >
> > > ============ test.xml ==============
> > > <?xml version="1.0"?>
> > >
> > > <!DOCTYPE page [
> > >    <!ENTITY values SYSTEM "test2.xml">
> > > ]>
> > >
> > > <page>
> > >    &values;
> > > </page>
> > > =====================================
> > >
> > > ============ test2.xml ==============
> > >
> > > <foo>
> > >    <bar>Some Text</bar>
> > > </foo>
> > > =====================================
> > >
> > > ============= test.xsl ==============
> > > <xsl:stylesheet
> > >    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> > >    xmlns="http://www.w3.org/TR/REC-html40";>
> > >
> > >    <xsl:output method="html" indent="yes"/>
> > >
> > >    <xsl:template match="page">
> > >       <html><body>
> > >       <xsl:value-of select="//bar"/>
> > >       </body></html>
> > >    </xsl:template>
> > >
> > > </xsl:stylesheet>
> > > =====================================
> > >

Reply via email to