You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Davide <da...@aliceposta.it> on 2003/12/31 14:27:36 UTC

Transformer - Sax - How to edit attributes?

Hi, i'm creating a transformer to edit links...

in my transformer i've the following method (i've simplified it to put 
here...):

public void startElement(String uri, String name, String raw,Attributes 
attr)throws SAXException {


         //The following edits the value of the href attribute, and returns 
a string with the new value...

         String newAttrValue=transformLink(attr.getValue("href"), BASE_URL)

         super.startElement(uri, name, raw, newAttrValue?????);

}

so, i need to simply copy the element, i've only to edit the href attribute 
(I want to copy all the other attributes); the new value of href is in 
"newAttrValue", but is a String... how to put the new href value as an 
attribute together all the others?

Best Regards, Davide 

Re: esql logicsheet and date

Posted by Jürgen Haas <no...@gmx.de>.
Hi,

maybe you should have a look in your database's manual. For example you can
use

INSERT INTO table (date_column) VALUES (now());

for inserting the current date (and time) into the column.
The result may be different, depending on the data type of the column. Type
date will result in 2004-01-03 and e. g. timestamp will be 2004-01-03
16:03:22.12345

HTH
Jürgen


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


esql logicsheet and date

Posted by Davide <da...@aliceposta.it>.
Hi!

I need to use esql to perform a query to put some data in a mysql db;

In the used table i have a Date column with timestamp(14) data type

In my xsp i get the date by <xsp:expr>new Date()</xsp:expr> but i think the 
format is very differen. How can i use a compatible format? Are there some 
utilities for dates and db?

Best Regards, Davide



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Trouble transforming EMPTY tag [Cocoon 2.1.4]

Posted by Matteo <tu...@email.it>.
Thanks you very much... i'm very new to cocoon (only a week) ;)

    Matteo

J.Pietschmann wrote:

>
> That's because you are serializing as HTML. HTML is not
> XML. THere is no closing tag for IMG necesary.
> If you want XHTML, try
>  <map:serialize type="xml"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Trouble transforming EMPTY tag [Cocoon 2.1.4]

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Matteo wrote:
>                <map:serialize type="html"/>
...
> <img alt="logo" src="data/image/oilogo.jpg"></body>
> </html>
> 
> Any clue why the <img> doesn't end with <img/>?
> Thanks in advance for the help!

That's because you are serializing as HTML. HTML is not
XML. THere is no closing tag for IMG necesary.
If you want XHTML, try
  <map:serialize type="xml"/>

Older browsers will choke on the generated XHTML though.

There is no easy standard method to serialize XHTML, in a
way which generates both valid XML and code acceptable to
older browsers (<br /> instead of <br/>).

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Trouble transforming EMPTY tag [Cocoon 2.1.4]

Posted by Matteo <tu...@email.it>.
Problem description:
When a try to transform an empty tag from an XML content to an HTML 
formatting the resulting tag in the HTML page has not the closing part.



Code Example (this example is semplified but I tested it doesn't work 
the same way the original problem):

here is the XML file with the content (test.xml):
<page>
    <logo/>
</page>

here is the XSL stylesheet (test2html.xsl)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="page">
        <html>
        <head>
            <title>test</title>
        </head>
        <body>
            <xsl:apply-templates select="logo"/>
        </body>
        </html>
    </xsl:template>
    <xsl:template match="logo">
        <img src="data/image/oilogo.jpg" alt="logo"></img>
    </xsl:template>
</xsl:stylesheet>

here is the sitemap entry for the page (extract from sitemap.xmap):
        <map:pipeline>
            <map:match pattern="test.htm">
                <map:generate src="laos/xml/test.xml"/>
                <map:transform src="laos/xsl/test2html.xsl"/>
                <map:serialize type="html"/>
            </map:match>
        </map:pipeline>

here is the resulting html code from transformation (test.htm):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>test</title>
</head>
<body>
<img alt="logo" src="data/image/oilogo.jpg"></body>
</html>

Any clue why the <img> doesn't end with <img/>?
Thanks in advance for the help!

    Matteo


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how to get the user agent in an xsp page?

Posted by Simon Mieth <si...@t-online.de>.
On Sat, 03 Jan 2004 01:54:59 +0100
Davide <da...@aliceposta.it> wrote:

> Hi, my question il simple:
> 
> how to get the user agent in an xsp page?
> 
> Best Regards, Davide
> 
Hi,

 <xsp-request:get-header name="user-agent" as="xml"/>

 or this

 <xsp:expr>request.getHeader("user-agent")</xsp:expr>


Best regards,

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


how to get the user agent in an xsp page?

Posted by Davide <da...@aliceposta.it>.
Hi, my question il simple:

how to get the user agent in an xsp page?

Best Regards, Davide



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: session transformer and xsp-session logicsheet

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Davide dijo:
> Hi.
>
> I want to get the user name of the authenticated user in my xsp;
>
> now i have <session:getxml context="authentication"
> path="/authentication/ID"/> but i have to apply the session transformer
>
> how could i use <xsp-session:????? /> to get it?

http://wiki.cocoondev.org/Wiki.jsp?page=XspSessionFw

Best Regards,

Antonio Gallardo


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


session transformer and xsp-session logicsheet

Posted by Davide <da...@aliceposta.it>.
Hi.

I want to get the user name of the authenticated user in my xsp;

now i have <session:getxml context="authentication" 
path="/authentication/ID"/> but i have to apply the session transformer

how could i use <xsp-session:????? /> to get it?

bset regards, Davide



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: getting request parameters in the sitemap

Posted by Jorg Heymans <jh...@domek.be>.
> <map:match pattern="body">
>     <map:act type="auth-protect">
>         <map:parameter name="handler" value="navigation"/>
>         <map:parameter name="use-request-parameters" value="true"/>
>        
<map:generate type="proxy" label="xml" src="{request-param:link}"/>
or maybe
<map:generate type="proxy" label="xml" src="../{request-param:link}"/>


>     </map:act>
> </map:match>
> 
> i call it with a "link" param containing the url, for example: 
> body?link=www.site.org
> My problem is how to use the value of the link param as value for the 
> src param of the wsproxy generator?
> 
> Best Regards, Davide


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


getting request parameters in the sitemap

Posted by Davide <da...@aliceposta.it>.
Hi, I have a problem...

I'm building something like a portal where i have a header generated by 
cocoon and a body where i can have any xhtml page in the web...

I did it with cinclude aggregation but i had some "style" problems because 
when the web page had a css changed also the style of the header. So i want 
to use frames....

to retreive the web page i think to use the ws proxy generator; i need this 
because i want also to apply transformation on if; my pipeline for wsproxy is:

<map:match pattern="body">
	<map:act type="auth-protect">
		<map:parameter name="handler" value="navigation"/>
		<map:parameter name="use-request-parameters" value="true"/>
		
		<map:generate type="proxy" label="xml" src="????????"/>
	</map:act>
</map:match>

i call it with a "link" param containing the url, for example: 
body?link=www.site.org
My problem is how to use the value of the link param as value for the src 
param of the wsproxy generator?

Best Regards, Davide



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Transformer - Sax - How to edit attributes?

Posted by Marc Portier <mp...@outerthought.org>.

Davide wrote:

> Hi, i'm creating a transformer to edit links...
> 
> in my transformer i've the following method (i've simplified it to put 
> here...):
> 
> *public* *void* startElement(String uri, String name, String 
> raw,Attributes attr)*throws* SAXException {
> 

pls try to use text-only mails on public mailing-lists

> 
>         //The following edits the value of the href attribute, and 
> returns a string with the new value...
>         
>         String newAttrValue=transformLink(attr.getValue("href"), BASE_URL)
> 
> *        super*.startElement(uri, name, raw, newAttrValue?????);
> 

nope, you have to pass an instance of Attributes there, not a String

the odd thing about the Attributes interface is that it doesn't allow to 
modify the set, so you can't modify the atts that were passed in...

you can use a new instance of org.xml.sax.helpers.AttributesImpl though

see 
http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/helpers/AttributesImpl.html
for the API of that thing

> }
> 
> so, i need to simply copy the element, i've only to edit the href 
> attribute (I want to copy all the other attributes); the new value of 
> href is in "newAttrValue", but is a String... how to put the new href 
> value as an attribute together all the others?
> 


so here goes

//warning uncompiled code
import org.xml.sax.helpers.AttributesImpl;

..

public void startElement(String uri, String name, String raw, Attributes 
attr) throws SAXException {
   ..
     AttributesImpl atts = new AttributesImpl(attr);
     int hrefNdx = atts.getIndex("href");
     String oldHrefValue = atts.getValue(hrefNdx);
     String newHrefValue = transformLink(oldHrefValue , BASE_URL);
     atts.setValue(hrefNdx, newHrefValue);
   ..
}

HTH,
-marc=
-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo@outerthought.org                              mpo@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org