You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Joshua Chamas <jo...@chamas.com> on 2002/04/02 10:42:38 UTC

Re: Apache::ASP 2.31 ParseXMLSubs Trouble

[[ Anyone working with XML & XMLSubs might want to read this ]]

Marcus Zoller wrote:
> 
> Hi! Here is some change I made...
> 
> The first line in ASP::ParseXMLSubs removes any <?xml version ... ?>
> parser directive. This is a big problem when the encoding information
> is required because the parser assumes it is UTF-8 if no encoding was
> set.
> 
> I removed the line and now anything works fine. Maybe this should be
> removed at all in the next release.. I can't see any reason to cut that
> instruction from the document...!?
> 

This is the offending Apache::ASP code:

    unless($self->{asp}{xslt}) {
	$data =~ s|\s*\<\?xml\s+version\s*\=[^\>]+\?\>||is;
    }

and it was put there with the idea that XMLSubs could be used
to fully render an XML document.  In sample XML hello world type
docs, this could work by just ripping the tag out.  I am not
saying it should stay but that is why it is there...

Perhaps if there were a secondary check on the ContentType, and
only if its a text/html doc will it rip out the <?xml version ...>
type tags on the fly ( not at parse time )? What ContentType would 
be set when serving just a .xml file in your case?  text/xml?

Or are your filtering XML to a post processor like AxKit ?

The code could be moved from from the parse phase to 
the flush phase for text/html docs only with XMLSubs turned on, 
but that really begs the question whether XMLSubs functionality 
should even care about tags like <?xml...>. It seems like in an 
effort to be able to deal with XML docs all on its own, it 
should offer some mechanism for dealing with this tags too, 
but am at a loss for how this should be done.

Any ideas?

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Apache::ASP 2.31 ParseXMLSubs Trouble

Posted by Joshua Chamas <jo...@chamas.com>.
Marcus Zoller wrote:
> 
> Am Die, 2002-04-02 um 22.39 schrieb Joshua Chamas:
> > Marcus Zoller wrote:
> > >
> > > > and it was put there with the idea that XMLSubs could be used
> > > > to fully render an XML document.  In sample XML hello world type
> > > > docs, this could work by just ripping the tag out.  I am not
> > > > saying it should stay but that is why it is there...
> > >
> > Right.  In the case of the XSLT layer in Apache::ASP, the
> > XML tag stripping is not done, are you using some other
> > XSLT layer post output?
> >
> 
> I wasn't looking at the unless {} in detail... sorry! The problem
> seems to be that {xslt} is undef in my setup...
> 

The expression was $self->{asp}{xslt} but should have been 
$self->{xslt}, sorry.  This will be fixed in Apache::ASP 2.33
which I will release in the next week.

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Apache::ASP 2.31 ParseXMLSubs Trouble

Posted by Marcus Zoller <Ma...@idnt.net>.
Am Die, 2002-04-02 um 22.39 schrieb Joshua Chamas:
> Marcus Zoller wrote:
> > 
> > > and it was put there with the idea that XMLSubs could be used
> > > to fully render an XML document.  In sample XML hello world type
> > > docs, this could work by just ripping the tag out.  I am not
> > > saying it should stay but that is why it is there...
> > 
> Right.  In the case of the XSLT layer in Apache::ASP, the 
> XML tag stripping is not done, are you using some other 
> XSLT layer post output?
> 

I wasn't looking at the unless {} in detail... sorry! The problem
seems to be that {xslt} is undef in my setup...

Now, here is what I did and what happened in detail:

content of .htaccess
--------------------
PerlSetVar XSLT /var/www/site/intranet.idnt.net/xsl/german.xsl

The output directive in the .xslt file is:

<xsl:output encoding="iso-8859-1" method="html" version="4.01"
media-type="text/html" indent="yes"/>

First line of the ASP document:
-------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>

As long as there are no german characters within the XML
document anything worked fine. With german characters the
parser returned:

XSLT/XML processing error: Entity: line 37: error: Input is not proper
UTF-8, indicate encoding !

I wondered about the UTF-8 and the only thing that may be the
reason for for that is a missing parser directive. That's why I searched
in the source for something that removes the line and this was
ParseXMLSubs. Removing the line solved the problem. 

Now, why is xslt undefined? I will try to get deeper into the code and
follow that... or is there something I did wrong?


Thanks for your help!
 
-- 

Marcus

.......................................................................
The finest in secure communication technologies:    http://www.idnt.net

IDNT Integrated Digital Network Technologies     Tel. +49 6403 9526 0
Perchstetten 14-16, 35428 Langgoens, Germany     Fax. +49 6403 9526 503
.......................................................................


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Apache::ASP 2.31 ParseXMLSubs Trouble

Posted by Joshua Chamas <jo...@chamas.com>.
Marcus Zoller wrote:
> 
> > and it was put there with the idea that XMLSubs could be used
> > to fully render an XML document.  In sample XML hello world type
> > docs, this could work by just ripping the tag out.  I am not
> > saying it should stay but that is why it is there...
> 
> So removing the tag is only required when working with XMLSubs
> in plain HTML documents.I think the term XMLSubs may cause some
> misunderstanding of the functionality behind... it has nothing
> in common with an XML document or any kind of XML processing.
> XMLSubs doesn't require an processing instruction, namespace
> declarations or anything else because it never gets handled
> or validated by an XML parser.
> 

Removing the XML tag would only be relevant when outputting
text/html from an XML source document.  It is my intention that
XMLSubs functionality be able to fully render an XML document
without an XSLT layer or other post processing.

So my suggestion then to accommodate your request is to possibly
look for text/html being set for the $Response->{ContentType}
which is the default, and if that is set, and if not rendering
through Apache::ASP XSLT, then deal with the XML declarations 
accordingly. But I do not know what ContentType you are setting if any,
so don't know if this would work for you.  If you could set
text/xml or some such, then this might be a solution.

> In case of XSL processing the information is required because
> the result of the ASP processing is an XML document that
> must be transformed by the XSLT engine.
> 

Right.  In the case of the XSLT layer in Apache::ASP, the 
XML tag stripping is not done, are you using some other 
XSLT layer post output?

So then what kind of XSLT are you doing that you need
the XML doc served as an XML doc untouched with regards
to the XML declaration & other processing tags ? 

Thanks,

Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Apache::ASP 2.31 ParseXMLSubs Trouble

Posted by Marcus Zoller <Ma...@idnt.net>.
Am Die, 2002-04-02 um 10.42 schrieb Joshua Chamas:
> 
> Marcus Zoller wrote:
> > 
> > The first line in ASP::ParseXMLSubs removes any <?xml version ... ?>
...
> > I removed the line and now anything works fine. Maybe this should be
> > removed at all in the next release.. I can't see any reason to cut that
> > instruction from the document...!?
> 
> This is the offending Apache::ASP code:
> 
>     unless($self->{asp}{xslt}) {
> 	$data =~ s|\s*\<\?xml\s+version\s*\=[^\>]+\?\>||is;
>     }
> 
> and it was put there with the idea that XMLSubs could be used
> to fully render an XML document.  In sample XML hello world type
> docs, this could work by just ripping the tag out.  I am not
> saying it should stay but that is why it is there...

So removing the tag is only required when working with XMLSubs
in plain HTML documents.I think the term XMLSubs may cause some
misunderstanding of the functionality behind... it has nothing 
in common with an XML document or any kind of XML processing.
XMLSubs doesn't require an processing instruction, namespace
declarations or anything else because it never gets handled
or validated by an XML parser. 

In case of XSL processing the information is required because
the result of the ASP processing is an XML document that 
must be transformed by the XSLT engine. 

Maybe this is a useful way to determine if tag tag should be 
removed or not (XSLT stylesheet perlvar is set or not) -> result is an
XML document to transform by the XSLT engine or a plain HTML document.

-- 

Marcus Zoller

.......................................................................
The finest in secure communication technologies:    http://www.idnt.net

IDNT Integrated Digital Network Technologies     Tel. +49 6403 9526 0
Perchstetten 14-16, 35428 Langgoens, Germany     Fax. +49 6403 9526 503
.......................................................................


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org