You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Nick Aliwell <ni...@mac.com> on 2005/11/13 12:36:20 UTC

parameter-doctype.xmap

Is parameter-doctype.xmap cached somewhere. Any changes i make to it  
dont seem to be picked up?
If it is, how can i clear it or temporarily turn caching off?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: parameter-doctype.xmap

Posted by so...@gmail.com.
On 11/13/05, Nick Aliwell <ni...@mac.com> wrote:
> Hi Solprovider,
>
> Thanks for the advice and thanks for the lenya site, its been a good
> resource so far.

You are welcome.

> I was actually working with a sample of yours i found on this list.
> My issue is that im trying to create an index page to list all the
> articles in the section with article date and perhaps an article
> abstract.  I figured that as all this type of info is stored in the
> metadata for the standard document type i could use that for my
> articles and then use the xpathdirectory generator to create an xml
> representation of all the articles with the metadata and use that xml
> to create the article list page. Heres what i had so far...
>  [CODE REMOVED]
> could i still achieve the same end result with the multiple
> stylesheets example?
No.

This is why it is very important to discover the business need rather
than the technical ideas.  You are not displaying the same document
using different stylesheets.  You want to display an aggregation of
some fields from many documents.  Search results is closer to what you
want, but has tons of code and complications you do not need.

You were on the correct path, but chose the wrong implementation.  Use
a Usecase and the XPathDirectory Generator.  That is how I developed
our Newsletter Usecase, and it works very well.

I will document this much better sometime this week, but here is some
code to get you started.  The XPathDirectory Generator is only pulling
the Title and Description, so you will want to add other fields, such
as the dates.  I am pulling code from our Newsletter Usecase, and may
miss something, and have not tested this.  I changed it to display
only one language.  The results are XML; you will want another
transformation and serialization to HTML.  I removed some whitespace,
but this is still a very long post.

If you implement this correctly, and I did not miss something, then
adding "?lenya.usecase=blurbs" to any URL will show XML including the
Navigation Title, Document Title, and Description for every document
of the current language in your publication.

FILE: usecase-blurbs.xmap
(Add the normal wrapping code.)
     <map:match pattern="**">
        <map:match pattern="site">
          <map:generate src="../content/live/sitetree.xml"/>
          <map:transform src="bsitetree.xsl"/>
          <!-- pages/page/title,path,language -->
          <map:serialize type="xml"/>
        </map:match>
        <map:match pattern="description">
          <map:generate type="xpathdirectory" src="../content/live">
            <map:parameter name="xpath"
value="/*[local-name()='html']/*[local-name()='meta']/*[local-name()='title']|/*[local-name()='html']/*[local-name()='meta']/*[local-name()='description']"/>
            <map:parameter name="xmlFiles" value="\.xml$"/>
            <map:parameter name="depth" value="99"/>
          </map:generate>
          <!-- Mess of all files -->
          <map:transform src="bblurbs.xsl"/>
          <map:serialize type="xml"/>
        </map:match>
<!-- Default --><map:aggregate element="content">
            <map:part src="cocoon:/site"/>
            <map:part src="cocoon:/description"/>
          </map:aggregate>
          <map:transform src="bcontent.xsl">
<map:parameter name="languagecode" value="{page-envelope:document-language}"/>
</map:transform>
          <map:serialize type="xml"/><!-- You want HTML -->
        </map:match>

FILE: bsitetree.xsl
<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tree="http://apache.org/cocoon/lenya/sitetree/1.0">
<xsl:template match="tree:site">
<pages><xsl:apply-templates select="tree:node"/></pages>
</xsl:template>
<xsl:template match="tree:node">
   <xsl:param name="path" select="''"/>
   <xsl:apply-templates select="tree:label"><xsl:with-param
name="path" select="concat($path, '/', @id)"/></xsl:apply-templates>
   <xsl:apply-templates select="tree:node"><xsl:with-param name="path"
select="concat($path, '/', @id)"/></xsl:apply-templates>
</xsl:template>
<xsl:template match="tree:label">
  <xsl:param name="path" select="''"/>
<xsl:element name="page">
<xsl:attribute name="id"><xsl:value-of select="$path"/></xsl:attribute>
<xsl:attribute name="language"><xsl:value-of
select="@xml:lang"/></xsl:attribute>
<title><xsl:value-of select="."/></title>
</xsl:element>
</xsl:template></xsl:stylesheet>

FILE: bblurbs.xsl
<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dir="http://apache.org/cocoon/directory/2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:template match="/dir:directory" priority="3">
<files><xsl:apply-templates select="dir:directory"/></files>
</xsl:template>
<xsl:template match="dir:directory">
   <xsl:param name="path" select="''"/>
   <xsl:apply-templates select="dir:file"><xsl:with-param name="path"
select="concat($path, '/', @name)"/></xsl:apply-templates>
   <xsl:apply-templates select="dir:directory"><xsl:with-param
name="path" select="concat($path, '/', @name)"/></xsl:apply-templates>
</xsl:template>
<xsl:template match="dir:file[contains(@name, '_')]">
<xsl:param name="path" select="''"/>
<xsl:element name="file">
<xsl:attribute name="id"><xsl:value-of select="$path"/></xsl:attribute>
<xsl:attribute name="language"><xsl:value-of
select="substring-before(substring-after(@name, '_'),
'.')"/></xsl:attribute>
<xsl:attribute name="idl"><xsl:value-of select="$path"/>_<xsl:value-of
select="substring-before(substring-after(@name, '_'),
'.')"/></xsl:attribute>
<xsl:apply-templates select="dir:xpath/dc:title"/>
<xsl:apply-templates select="dir:xpath/dc:description"/>
</xsl:element>
</xsl:template>
<xsl:template match="dc:title">
<title><xsl:value-of select="."/></title>
</xsl:template>
<xsl:template match="dc:description">
<description><xsl:value-of select="."/></description>
</xsl:template></xsl:stylesheet>

FILE: bcontent.xsl
<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="languagecode"/>
<xsl:template match="/content">
<xsl:apply-templates select="pages"/>
</xsl:template>
<xsl:template match="pages">
<pages>
<xsl:apply-templates select="page[@language=$languagecode]"/>
</pages>
</xsl:template>
<xsl:template match="page">
<xsl:variable name="idl"><xsl:value-of select="@id"/>_<xsl:value-of
select="@language"/></xsl:variable>
<xsl:variable name="desc"><xsl:value-of
select="/content/files/file[@idl=$idl]/description"/></xsl:variable>
<xsl:if test="string-length(normalize-space($desc)) &gt; 0">
<xsl:element name="item">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="idl"><xsl:value-of select="$idl"/></xsl:attribute>
<xsl:attribute name="language"><xsl:value-of
select="@language"/></xsl:attribute>
<navtitle><xsl:value-of select="title"/></navtitle>
<doctitle><xsl:value-of
select="/content/files/file[@idl=$idl]/title"/></doctitle>
<description><xsl:value-of select="$desc"/></description>
</xsl:element>
</xsl:if>
</xsl:template>
<!-- Remove excess tags --><xsl:template match="@*|node()"
priority="-1"/></xsl:stylesheet>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: parameter-doctype.xmap

Posted by Nick Aliwell <ni...@mac.com>.
Hi Solprovider,

Thanks for the advice and thanks for the lenya site, its been a good  
resource so far.

I was actually working with a sample of yours i found on this list.  
My issue is that im trying to create an index page to list all the  
articles in the section with article date and perhaps an article  
abstract.  I figured that as all this type of info is stored in the  
metadata for the standard document type i could use that for my  
articles and then use the xpathdirectory generator to create an xml  
representation of all the articles with the metadata and use that xml  
to create the article list page. Heres what i had so far...

in parameter-doctype.xmap

     <map:pipeline>
       <map:match pattern="*/pressreleases*.html">
         <map:generate type="serverpages" src="../../config/ 
parameters/default.xsp">
           <map:parameter name="value" value="articlelist"/>
         </map:generate>
         <map:serialize type="xml"/>
       </map:match>
     </map:pipeline>


in doctypes.xmap

       <map:match pattern="*/*/articlelist/**.xml">
		<map:generate type="xpathdirectory" src="content/authoring/tutorial/ 
pressreleases">
			<map:parameter name="xpath" value="/*[local-name()='html']/*[local- 
name()='meta']/*[local-name()='title']|/*[local-name()='html']/* 
[local-name()='meta']/*[local-name()='subject']|/*[local-name() 
='html']/*[local-name()='meta']/*[local-name()='description']|/* 
[local-name()='html']/*[local-name()='meta']/*[local-name()='date']"/>
			<map:parameter name="xmlFiles" value="\.xml$" />
			<map:parameter name="depth" value="2"/>
		</map:generate>
	<!-- preprep.xsl just takes the data i need and makes a more  
sensible xml file -->
         <map:transform src="lenya/xslt/navigation/prprep.xsl">
         </map:transform>
	<!-- articlelist.xsl creates the html i need to list all the  
articles -->
         <map:transform src="lenya/xslt/navigation/articlelist.xsl">
         </map:transform>
         <map:transform src="xslt/articlelist2xhtml.xsl">
           <map:parameter name="rendertype" value="{1}"/>
           <map:parameter name="nodeid" value="{page- 
envelope:document-node-id}"/>
           <map:parameter name="language" value="{page- 
envelope:document-language}"/>
         </map:transform>
		<map:serialize type="xml" />
       </map:match>


could i still achieve the same end result with the multiple  
stylesheets example?

Nick



On 13 Nov 2005, at 15:45, solprovider@gmail.com wrote:

> On 11/13/05, Nick Aliwell <ni...@mac.com> wrote:
>> Is parameter-doctype.xmap cached somewhere. Any changes i make to it
>> dont seem to be picked up?
>> If it is, how can i clear it or temporarily turn caching off?
>
> Yes, it is, which is annoying for new developers believing thay can
> control layout by overriding doctype.  The functionality you want can
> probably be handled with the code from:
> "Using Multiple Stylesheets for the Same Content"
> http://solprovider.com/lenya/multiple
>
> solprovider
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: parameter-doctype.xmap

Posted by so...@gmail.com.
On 11/13/05, Nick Aliwell <ni...@mac.com> wrote:
> Is parameter-doctype.xmap cached somewhere. Any changes i make to it
> dont seem to be picked up?
> If it is, how can i clear it or temporarily turn caching off?

Yes, it is, which is annoying for new developers believing thay can
control layout by overriding doctype.  The functionality you want can
probably be handled with the code from:
"Using Multiple Stylesheets for the Same Content"
http://solprovider.com/lenya/multiple

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org