On 17.05.2004 23:45, leon tian wrote:

Hi, thanks for the reply. But I wanna transform web pages from the
internet dynamically which means different css should be applied
based on different web pages. How can I get the url of each css
automatically (like a web browser)?

You mean my example was to simple as it was only one hardcoded remote resource?


With a pipeline of your current sitemap it would be easier for me to give an example, but maybe you see what I try to suggest:

1. Absolutize the links to the external resources:

Somewhere you have to determine where to get a web page from, don't you? This part you can pass into a stylesheet as parameter that absolutizes the links to CSS, JS and images.

<map:match pattern="remote.html">
  <map:generate type="html" src="{remoteserver}/index.html"/>
  <map:transform src="absolutize.xsl">
    <map:parameter name="remoteserver" value="{remoteserver}"/>
  </map:transform>
  <map:serialize/>
</map:match>

In the stylesheet you match on link/@href, style/@src, img/@src etc. and change all relative links:

<xsl:template match="link/@href">
  <xsl:attribute name="href">
    <xsl:value-of select="concat($remoteserver, '/', .)"/>
  </xsl:attribute>
</xsl:template>

The resources would be fetched from the remote server without any Cocoon inbetween.

2. forward the request to the remote server

<map:match pattern="remote.html">
  <map:generate type="html" src="{remoteserver}/index.html"/>
  <map:serialize/>
</map:match>

<map:match pattern="**.css">
  <map:read src="{remoteserver}/{0}"/>
</map:match>

In the same way you determine the remote URL for the web page you can do it for the CSS. And even if this is not possible, you can add a transformer into the remote.html pipeline that adds a hint on the remote server into all resource links (same as in approach 1). In the CSS pipeline you get them from the URL

<map:match pattern="remote.html">
  <map:generate type="html" src="{remoteserver}/index.html"/>
  <map:transform src="addRemoteServerHint">
    <map:parameter name="remoteserver" value="{remoteserver}"/>
  </map:transform>
  <map:serialize/>
</map:match>

<map:match pattern="*/**.css">
  <map:read src="http://{1}/{2}.css"/>
</map:match>

The difference is then only that those resources are delivered through Cocoon, not grabbed from the remote server directly.

Hope you get the ideas.

Joerg


Joerg Heinicke wrote: On 17.05.2004 15:53,

hi,

is there any way to apply the css of the original web pages from
the internet? after i transform web pages from the internet, most
of the styles are lost because they are linked to a css file on the
web site's server. should i try to download and apply them on my resulting pages and how?


It should be easy to forward the request to the CSS to the original server in the same way as you get the HTML source.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to