You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ali Mesbah <al...@West.NL> on 2003/04/04 13:53:58 UTC
escaping xml tags
I have an XSP which returns an XML document from the Xindice database.
result = get the document from Xindice;
<xsp:expr>result</xsp:expr>
It goes all well except that the document returned is escaped so it is not
actually XML anymore. Does anyone know how to tell XSP not to escape the result?
Thanks,
Ali
--
-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: escaping xml tags
Posted by Bert Van Kets <be...@vankets.com>.
Aparently your <xsp:expr>result</xsp:expr> returns a string and not and XML
stream.
You can use JTidy to convert your String to an XML stream. It's classes
are available in Cocoon!
Here's a code snip out of an XSP page that converts a POST from a brower
based html editor to an XML stream.
<xsp:structure>
<xsp:include>org.w3c.tidy.Tidy</xsp:include>
<xsp:include>java.io.ByteArrayInputStream</xsp:include>
</xsp:structure>
<page>
<xsp:logic>
String strContent = request.getParameter("content");
ByteArrayInputStream in = new ByteArrayInputStream(
strContent.getBytes() );
org.w3c.dom.Document doc = null;
org.w3c.tidy.Configuration conf = new org.w3c.tidy.Configuration();
try {
Tidy tidy = new Tidy();
//Do not show "parsing" messages
tidy.setQuiet(true);
//Do not show warnings in the Servlet Engine console
tidy.setShowWarnings(false);
//set the output type
tidy.setXmlOut(true);
//Set the encoding
tidy.setCharEncoding( conf.LATIN1 );
//Set output options
tidy.setBreakBeforeBR(false);
tidy.setQuoteNbsp(true);
tidy.setQuoteAmpersand(true);
tidy.setLiteralAttribs(true);
//Omit the document type in the tidy output
tidy.setXmlPi(false);
//parse the document tot a DOM tree
doc = tidy.parseDOM(in, null);
} catch (Exception e) {
//Do some error handling here
}
</xsp:logic>
<content>
<xsp:expr>doc.getDocumentElement()</xsp:expr>
</content>
You will need to tweak the Tidy parameters, but you get the idea, I guess.
The DOM stream from JTidy is automatically converted to SAX by Cocoon
(correct me if I'm wrong) so you can do regular transformations in the
pipeline afterwards.
HTH,
Bert
At 14:46 4/04/2003 +0100, you wrote:
>Don't know if this is the only way, nor how to do it in XSP, but what you
>want to do is
>parse the XML. In Java (e.g. in a custom generator) you could say is
>something like:
>
> InputSource inputSource = new InputSource(new
>ByteArrayInputStream(page.getBytes()));
> Parser parser = (Parser) manager.lookup(Parser.ROLE);
> parser.parse(inputSource, xmlConsumer);
>
>xmlConsumer is a handle for the next stage in a pipeline. I don't know if
>you can get
>hold of that in XSP.
>
>Anyway, hope that helps and isn't completely irrelevant!
>
>Regards, Upayavira
>
>On 4 Apr 2003 at 15:39, Ali Mesbah wrote:
>
> > > As quoted from Lionel Crine <cr...@4dconcept.fr>:
> > > > document returned is escaped -> What does that mean?
> > >
> > I would expect:
> >
> > <?xml version="1.0"?>
> > <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:noNamespaceSchemaLocation="person.xsd"
> > xmlns:src="http://xml.apache.org/xindice/Query"
> > src:col="/db/person"
> > src:key="632dd5400392cab7000000f4103a2d4f">
> >
> > <name>Marc</name>
> > <last_name>Jansen</last_name>
> > <phone>07503816784</phone>
> > <address>Laan 12</address>
> > <date_of_birth>1970-01-21</date_of_birth>
> > </person>
> >
> > but I get (this is what I call escaped):
> >
> > <?xml version="1.0"?>
> > <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:noNamespaceSchemaLocation="person.xsd"
> > xmlns:src="http://xml.apache.org/xindice/Query"
> > src:col="/db/person"
> > src:key="632dd5400392cab7000000f4103a2d4f">
> >
> > <name>Marc<name>
> > <last_name>Jansen</last_name>
> > <phone>07503816784</phone>
> > <address>Laan 12</address>
> > <date_of_birth>1970-01-21</date_of_birth>
> > </persongt;
> >
> >
> > > > Lionel
> > > >
> > > >
> > > > At 13:53 04/04/2003 +0200, you wrote:
> > > > >I have an XSP which returns an XML document from the Xindice
> > > > >database.
> > > > >
> > > > >result = get the document from Xindice;
> > > > >
> > > > ><xsp:expr>result</xsp:expr>
> > > > >
> > > > >It goes all well except that the document returned is escaped so
> > > > >it is not actually XML anymore. Does anyone know how to tell XSP
> > > > >not to escape the result?
> > > > >
> > > > >Thanks,
> > > > >Ali
> > > > >
> > > > >
> > > > >--
> > > > >-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> > > > >
> > > > >-----------------------------------------------------------------
> > > > >---- To unsubscribe, e-mail:
> > > > >cocoon-users-unsubscribe@xml.apache.org For additional commands,
> > > > >e-mail: cocoon-users-help@xml.apache.org
> > > >
> > > >
> > > > ------------------------------------------------------------------
> > > > --- To unsubscribe, e-mail:
> > > > cocoon-users-unsubscribe@xml.apache.org For additional commands,
> > > > e-mail: cocoon-users-help@xml.apache.org
> > > >
> > >
> > > --
> > > -- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> > >
> >
> > --
> > -- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org For
> > additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> >
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: escaping xml tags
Posted by Upayavira <uv...@upaya.co.uk>.
Don't know if this is the only way, nor how to do it in XSP, but what you want to do is
parse the XML. In Java (e.g. in a custom generator) you could say is something like:
InputSource inputSource = new InputSource(new
ByteArrayInputStream(page.getBytes()));
Parser parser = (Parser) manager.lookup(Parser.ROLE);
parser.parse(inputSource, xmlConsumer);
xmlConsumer is a handle for the next stage in a pipeline. I don't know if you can get
hold of that in XSP.
Anyway, hope that helps and isn't completely irrelevant!
Regards, Upayavira
On 4 Apr 2003 at 15:39, Ali Mesbah wrote:
> > As quoted from Lionel Crine <cr...@4dconcept.fr>:
> > > document returned is escaped -> What does that mean?
> >
> I would expect:
>
> <?xml version="1.0"?>
> <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="person.xsd"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/person"
> src:key="632dd5400392cab7000000f4103a2d4f">
>
> <name>Marc</name>
> <last_name>Jansen</last_name>
> <phone>07503816784</phone>
> <address>Laan 12</address>
> <date_of_birth>1970-01-21</date_of_birth>
> </person>
>
> but I get (this is what I call escaped):
>
> <?xml version="1.0"?>
> <person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="person.xsd"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/person"
> src:key="632dd5400392cab7000000f4103a2d4f">
>
> <name>Marc<name>
> <last_name>Jansen</last_name>
> <phone>07503816784</phone>
> <address>Laan 12</address>
> <date_of_birth>1970-01-21</date_of_birth>
> </persongt;
>
>
> > > Lionel
> > >
> > >
> > > At 13:53 04/04/2003 +0200, you wrote:
> > > >I have an XSP which returns an XML document from the Xindice
> > > >database.
> > > >
> > > >result = get the document from Xindice;
> > > >
> > > ><xsp:expr>result</xsp:expr>
> > > >
> > > >It goes all well except that the document returned is escaped so
> > > >it is not actually XML anymore. Does anyone know how to tell XSP
> > > >not to escape the result?
> > > >
> > > >Thanks,
> > > >Ali
> > > >
> > > >
> > > >--
> > > >-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> > > >
> > > >-----------------------------------------------------------------
> > > >---- To unsubscribe, e-mail:
> > > >cocoon-users-unsubscribe@xml.apache.org For additional commands,
> > > >e-mail: cocoon-users-help@xml.apache.org
> > >
> > >
> > > ------------------------------------------------------------------
> > > --- To unsubscribe, e-mail:
> > > cocoon-users-unsubscribe@xml.apache.org For additional commands,
> > > e-mail: cocoon-users-help@xml.apache.org
> > >
> >
> > --
> > -- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
>
> --
> -- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org For
> additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: escaping xml tags
Posted by Ali Mesbah <al...@West.NL>.
> As quoted from Lionel Crine <cr...@4dconcept.fr>:
> > document returned is escaped -> What does that mean?
>
I would expect:
<?xml version="1.0"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd"
xmlns:src="http://xml.apache.org/xindice/Query"
src:col="/db/person"
src:key="632dd5400392cab7000000f4103a2d4f">
<name>Marc</name>
<last_name>Jansen</last_name>
<phone>07503816784</phone>
<address>Laan 12</address>
<date_of_birth>1970-01-21</date_of_birth>
</person>
but I get (this is what I call escaped):
<?xml version="1.0"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd"
xmlns:src="http://xml.apache.org/xindice/Query"
src:col="/db/person"
src:key="632dd5400392cab7000000f4103a2d4f">
<name>Marc<name>
<last_name>Jansen</last_name>
<phone>07503816784</phone>
<address>Laan 12</address>
<date_of_birth>1970-01-21</date_of_birth>
</persongt;
> > Lionel
> >
> >
> > At 13:53 04/04/2003 +0200, you wrote:
> > >I have an XSP which returns an XML document from the Xindice database.
> > >
> > >result = get the document from Xindice;
> > >
> > ><xsp:expr>result</xsp:expr>
> > >
> > >It goes all well except that the document returned is escaped so it is not
> > >actually XML anymore. Does anyone know how to tell XSP not to escape the
> > >result?
> > >
> > >Thanks,
> > >Ali
> > >
> > >
> > >--
> > >-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > >For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
>
> --
> -- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
--
-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: escaping xml tags
Posted by Ali Mesbah <al...@West.NL>.
As quoted from Lionel Crine <cr...@4dconcept.fr>:
> document returned is escaped -> What does that mean?
I would expect:
<?xml version="1.0"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd"
xmlns:src="http://xml.apache.org/xindice/Query"
src:col="/db/person"
src:key="632dd5400392cab7000000f4103a2d4f">
<name>Marc</name>
<last_name>Jansen</last_name>
<phone>07503816784</phone>
<address>Laan 12</address>
<date_of_birth>1970-01-21</date_of_birth>
</person>
<?xml version="1.0"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="person.xsd"
xmlns:src="http://xml.apache.org/xindice/Query"
src:col="/db/person"
src:key="632dd5400392cab7000000f4103a2d4f">
<name>Marc<name>
<last_name>Jansen</last_name>
<phone>07503816784</phone>
<address>Laan 12</address>
<date_of_birth>1970-01-21</date_of_birth>
</persongt;
> Lionel
>
>
> At 13:53 04/04/2003 +0200, you wrote:
> >I have an XSP which returns an XML document from the Xindice database.
> >
> >result = get the document from Xindice;
> >
> ><xsp:expr>result</xsp:expr>
> >
> >It goes all well except that the document returned is escaped so it is not
> >actually XML anymore. Does anyone know how to tell XSP not to escape the
> >result?
> >
> >Thanks,
> >Ali
> >
> >
> >--
> >-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> >For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
--
-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: escaping xml tags
Posted by Lionel Crine <cr...@4dconcept.fr>.
document returned is escaped -> What does that mean?
Lionel
At 13:53 04/04/2003 +0200, you wrote:
>I have an XSP which returns an XML document from the Xindice database.
>
>result = get the document from Xindice;
>
><xsp:expr>result</xsp:expr>
>
>It goes all well except that the document returned is escaped so it is not
>actually XML anymore. Does anyone know how to tell XSP not to escape the
>result?
>
>Thanks,
>Ali
>
>
>--
>-- Ali Mesbah, West Consulting B.V., www.west.nl, +31 15 2191600
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org