You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Miroslav Mocek <mm...@seznam.cz> on 2005/10/05 02:02:24 UTC

Using XML db as the source of xml files

Hello,

I have a set of XML files (in my own vocabulary) in some directory 
structure. I was thinking of generating my site from the files. (I would 
definitely need the recursing directory approach, because there is a lot 
of files and it will be dynamic archive. As stated in user maillist - 
'create a custom sitemap entry that uses the DirectoryGenerator from 
Cocoon'. Well, I'm not quite sure, how to get that working...)

But now I'm thinking about converting the whole directory structure with 
files into native XML db (xindice - or do you know better? I am really 
new in this topic). And use forrest to generate the site from the XML db.
Is THAT possible? As I read documentation, it could be. Forrest 
documentation says: 'one can - Read content from exotic sources like XML 
databases'. Had someone already tried that?

Thanks a lot for suggestions,
Mirek


Re: Using XML db as the source of xml files

Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
> El jue, 06-10-2005 a las 00:22 +0200, Miroslav Mocek escribió:
> 
>>ok, I am really lost, so I tried to get first DirectoryGenerator 
>>running. (should be simpler, I hope)
>>
>>I wasn't successfull. What I did:
>>
>>I've created subdir "my" in content/xdocs and put 2 files in it - 
>>first.xml and second.xml (which are just easier versions of index.xml now)
>>
>>I've put this 3 lines in my sitemap.xmap. (found in 
>>http://cocoon.zones.apache.org/demos/release/docs/userdocs/generators/directory-generator.html)
>><map:match pattern="my*">
> 
> 
> try <map:match pattern="my">

This will generate with the file reader not with the directory 
generator. Miroslav see Cocoon docs on how to use generators (linked in 
Thorsetens mail).

Ross


Re: Using XML db as the source of xml files

Posted by Thorsten Scherler <th...@apache.org>.
El jue, 06-10-2005 a las 00:22 +0200, Miroslav Mocek escribió:
> ok, I am really lost, so I tried to get first DirectoryGenerator 
> running. (should be simpler, I hope)
> 
> I wasn't successfull. What I did:
> 
> I've created subdir "my" in content/xdocs and put 2 files in it - 
> first.xml and second.xml (which are just easier versions of index.xml now)
> 
> I've put this 3 lines in my sitemap.xmap. (found in 
> http://cocoon.zones.apache.org/demos/release/docs/userdocs/generators/directory-generator.html)
> <map:match pattern="my*">

try <map:match pattern="my">

>     <map:generate src="my"/>
>     </map:match>
> 
> before the
>    <map:match pattern="**.xml">
> 
> I've created element in site.xml:
> <dirLink label="myaddr" href="my/" />

try <dirLink label="myaddr" href="my" />

> 
> And used the link in index.xml as:
> <link href="site:dirLink">link for my dir</link>.
> 
> The link is transformed as http://localhost:8888/my/ - it's ok.
> But when I click on the link, I get 'The requested resource "/my/" could 
> not be found.'
> 
> I think, my sitemap.xmap configuration is wrong. But I cannot find any 
> documentation how to do it right.

try:
http://cocoon.apache.org/2.1/userdocs/generators/generators.html
for an overview.
try:
http://cocoon.apache.org/2.1/userdocs/generators/directory-generator.html
for directory-generator

*BUT* seeing the subject line, you really want:
http://cocoon.apache.org/2.1/userdocs/generators/xmldb-generator.html
but:
Warning!
The XML:DB generators are currently unmaintained and going to be
deprecated soon. Please use the XML:DB pseudo-protocol instead. 


HTH
salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Miroslav Mocek <mm...@seznam.cz>.
WOW, finally!

the trick is in {project:content.xdocs}. If you don't specify it, you'll 
get the error of non existing resource... If you specify it, the xml 
with listing of files in directory appears as it is the most obvious 
thing, it ever does... and how can I expect it will be not working? ;)
<map:generate type="directory" src="{project:content.xdocs}/my">  ... ok

Thanks for help,
Mirek

Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Miroslav Mocek <mm...@seznam.cz>.
Great! Thanks!
Mirek


Thorsten Scherler wrote:

>In addition:
>
>You will then need to request 
>localhost:8888/my.html
>
>  
>

>salu2
>
>El jue, 06-10-2005 a las 14:06 +0200, Thorsten Scherler escribió:
>  
>
>>Try changing 
>><map:match pattern="my">
>>
>>to
>><map:match pattern="my.xml">
>>
>>IMO that should do the job.
>>
>>El jue, 06-10-2005 a las 13:59 +0200, Miroslav Mocek escribió:
>>    
>>
>>>I'd like to create index with links to the files in the dir.
>>>
>>>I've wrote xsl, which produces this xml document:
>>>
>>><document>
>>>   <header>
>>><title>Welcome to MyProj</title>
>>></header>
>>>    <body>
>>>    <section id="overview">
>>><link href="http://localhost:8888/my/first.xml">first</link>
>>><link href="http://localhost:8888/my/second.xml">second</link>
>>></section>
>>></body>
>>></document>
>>>
>>>Is is called is sitemap.xmap:
>>><map:match pattern="my">
>>><map:generate type="directory" src="{project:content.xdocs}/my">
>>>    <map:parameter name="depth" value="2"/>
>>>  </map:generate> 
>>><map:transform src="resources/stylesheets/directory2document.xsl"/>
>>>  <map:serialize type="xml"/>
>>></map:match>
>>>
>>>However I get only the xml (complete paste above) as result, not skinned 
>>>html. 
>>>(http://forrest.apache.org/docs_0_80/your-project.html#adding_new_content_type 
>>>- That will intercept the request for the body content, for only this 
>>>specific "download" document, and will transform it into the 
>>>intermediate Forrest "document" format. The normal Forrest machinery 
>>>will handle the aggregation with navigation menus etc. and will apply 
>>>the normal skin.)
>>>
>>>? Thanks
>>>Mirek
>>>
>>>      
>>>


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Thorsten Scherler <th...@apache.org>.
In addition:

You will then need to request 
localhost:8888/my.html

salu2

El jue, 06-10-2005 a las 14:06 +0200, Thorsten Scherler escribió:
> Try changing 
> <map:match pattern="my">
> 
> to
> <map:match pattern="my.xml">
> 
> IMO that should do the job.
> 
> El jue, 06-10-2005 a las 13:59 +0200, Miroslav Mocek escribió:
> > I'd like to create index with links to the files in the dir.
> > 
> > I've wrote xsl, which produces this xml document:
> > 
> > <document>
> >    <header>
> > <title>Welcome to MyProj</title>
> > </header>
> >     <body>
> >     <section id="overview">
> > <link href="http://localhost:8888/my/first.xml">first</link>
> > <link href="http://localhost:8888/my/second.xml">second</link>
> > </section>
> > </body>
> > </document>
> > 
> > Is is called is sitemap.xmap:
> > <map:match pattern="my">
> > <map:generate type="directory" src="{project:content.xdocs}/my">
> >     <map:parameter name="depth" value="2"/>
> >   </map:generate> 
> > <map:transform src="resources/stylesheets/directory2document.xsl"/>
> >   <map:serialize type="xml"/>
> > </map:match>
> > 
> > However I get only the xml (complete paste above) as result, not skinned 
> > html. 
> > (http://forrest.apache.org/docs_0_80/your-project.html#adding_new_content_type 
> > - That will intercept the request for the body content, for only this 
> > specific "download" document, and will transform it into the 
> > intermediate Forrest "document" format. The normal Forrest machinery 
> > will handle the aggregation with navigation menus etc. and will apply 
> > the normal skin.)
> > 
> > ? Thanks
> > Mirek
> > 
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Thorsten Scherler <th...@apache.org>.
Try changing 
<map:match pattern="my">

to
<map:match pattern="my.xml">

IMO that should do the job.

El jue, 06-10-2005 a las 13:59 +0200, Miroslav Mocek escribió:
> I'd like to create index with links to the files in the dir.
> 
> I've wrote xsl, which produces this xml document:
> 
> <document>
>    <header>
> <title>Welcome to MyProj</title>
> </header>
>     <body>
>     <section id="overview">
> <link href="http://localhost:8888/my/first.xml">first</link>
> <link href="http://localhost:8888/my/second.xml">second</link>
> </section>
> </body>
> </document>
> 
> Is is called is sitemap.xmap:
> <map:match pattern="my">
> <map:generate type="directory" src="{project:content.xdocs}/my">
>     <map:parameter name="depth" value="2"/>
>   </map:generate> 
> <map:transform src="resources/stylesheets/directory2document.xsl"/>
>   <map:serialize type="xml"/>
> </map:match>
> 
> However I get only the xml (complete paste above) as result, not skinned 
> html. 
> (http://forrest.apache.org/docs_0_80/your-project.html#adding_new_content_type 
> - That will intercept the request for the body content, for only this 
> specific "download" document, and will transform it into the 
> intermediate Forrest "document" format. The normal Forrest machinery 
> will handle the aggregation with navigation menus etc. and will apply 
> the normal skin.)
> 
> ? Thanks
> Mirek
> 
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Miroslav Mocek <mm...@seznam.cz>.
I'd like to create index with links to the files in the dir.

I've wrote xsl, which produces this xml document:

<document>
   <header>
<title>Welcome to MyProj</title>
</header>
    <body>
    <section id="overview">
<link href="http://localhost:8888/my/first.xml">first</link>
<link href="http://localhost:8888/my/second.xml">second</link>
</section>
</body>
</document>

Is is called is sitemap.xmap:
<map:match pattern="my">
<map:generate type="directory" src="{project:content.xdocs}/my">
    <map:parameter name="depth" value="2"/>
  </map:generate> 
<map:transform src="resources/stylesheets/directory2document.xsl"/>
  <map:serialize type="xml"/>
</map:match>

However I get only the xml (complete paste above) as result, not skinned 
html. 
(http://forrest.apache.org/docs_0_80/your-project.html#adding_new_content_type 
- That will intercept the request for the body content, for only this 
specific "download" document, and will transform it into the 
intermediate Forrest "document" format. The normal Forrest machinery 
will handle the aggregation with navigation menus etc. and will apply 
the normal skin.)

? Thanks
Mirek


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Ross Gardler <rg...@apache.org>.
David Crossley wrote:
> Miroslav Mocek wrote:
> 

...

>>I think, my sitemap.xmap configuration is wrong. But I cannot find any 
>>documentation how to do it right.
>>Any suggestions?
>>Thanks Mirek
> 
> 
> Search the recent archives (late last month?) of the
> forrest mailing lists ("user" perhaps) where we helped
> someone to do that. It is not hard.
> 
> We should create a demo in the "seed-sample" site.

There is already a demo in SVN head: resume plugin:

       <map:match pattern="team/all.source.xml">
         <map:generate type="directory" 
src="{project:content.xdocs}/team/resume">
           <map:parameter name="include" value=".*.xml$"/>
         </map:generate>
         <map:transform src="resources/stylesheets/directory2resumes.xsl"/>
         <map:transform type="cinclude"/>
         <map:serialize type="xml"/>
       </map:match>

from 
http://svn.apache.org/repos/asf/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Resume/input.xmap

Ross


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Miroslav Mocek <mm...@seznam.cz>.
Yeah, it was not. ('I've created subdir "my" in content/xdocs and put 2 
files in it ')

It's working now.
Thanks
Mirek


Thorsten Scherler wrote:

>Make sure that the "my" dir is in the same level like the sitemap.
>
>like:
>.
>|-- my
>|-- content
>|   |-- locationmap.xml
>|   `-- xdocs
>...
>|       |-- tabs.xml
>|       `-- ...
>|-- resources
>|   |-- schema
>|   |   `-- catalog.xcat
>|   |-- stylesheets
>|   `-- templates
>|-- sitemap.xmap
>|-- skinconf.xml
>`-- translations
>
>Another example:
>http://svn.apache.org/viewcvs.cgi/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/output.xmap?view=markup
> <map:pipeline>
>    <map:match pattern="ls.contracts">
>      <map:generate type="directory" src="resources/templates">
>        <map:parameter name="depth" value="1"/>
>        <!-- sorted alphabetically -->
>      	<map:parameter name="reverse" value="false"/>
>      </map:generate>
>      <map:serialize type="xml"/>
>    </map:match>
>  </map:pipeline>
>
>salu2
>  
>


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Thorsten Scherler <th...@apache.org>.
El jue, 06-10-2005 a las 12:45 +0200, Miroslav Mocek escribió:
> Even with serializer, the same error.
> 
> I'm trying now to svn up and start again.
> Mirek
> 
> 
> ><map:match pattern="my">
> >  <map:generate type="directory" src="my">
> >    <map:parameter name="depth" value="2"/>
> >  </map:generate>  
> >  <map:serialize type="xml" />  
> ></map:match>
> >

Make sure that the "my" dir is in the same level like the sitemap.

like:
.
|-- my
|-- content
|   |-- locationmap.xml
|   `-- xdocs
...
|       |-- tabs.xml
|       `-- ...
|-- resources
|   |-- schema
|   |   `-- catalog.xcat
|   |-- stylesheets
|   `-- templates
|-- sitemap.xmap
|-- skinconf.xml
`-- translations

Another example:
http://svn.apache.org/viewcvs.cgi/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/output.xmap?view=markup
 <map:pipeline>
    <map:match pattern="ls.contracts">
      <map:generate type="directory" src="resources/templates">
        <map:parameter name="depth" value="1"/>
        <!-- sorted alphabetically -->
      	<map:parameter name="reverse" value="false"/>
      </map:generate>
      <map:serialize type="xml"/>
    </map:match>
  </map:pipeline>

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Miroslav Mocek <mm...@seznam.cz>.
Even with serializer, the same error.

I'm trying now to svn up and start again.
Mirek


><map:match pattern="my">
>  <map:generate type="directory" src="my">
>    <map:parameter name="depth" value="2"/>
>  </map:generate>  
>  <map:serialize type="xml" />  
></map:match>
>
>HTH
>  
>


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Thorsten Scherler <th...@apache.org>.
El jue, 06-10-2005 a las 12:19 +0200, Miroslav Mocek escribió:
> >>I've put this 3 lines in my sitemap.xmap. (found in 
> >>http://cocoon.zones.apache.org/demos/release/docs/userdocs/generators/directory-generator.html)
> >><map:match pattern="my*">
> >>   <map:generate src="my"/>
> >>   </map:match>
> >>    
> >>
> >
> >That is not what the page tells you to do.
> >Anyway, see below.
> >
> >  
> >
> ok, I used exact syntax from the page
> <map:match pattern="my">
> <map:generate type="directory" src="my">
>     <map:parameter name="depth" value="2"/>
>   </map:generate>    
>    </map:match>
> 

No serializer!

<map:match pattern="my">
  <map:generate type="directory" src="my">
    <map:parameter name="depth" value="2"/>
  </map:generate>  
  <map:serialize type="xml" />  
</map:match>

HTH
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by Miroslav Mocek <mm...@seznam.cz>.
>>I've put this 3 lines in my sitemap.xmap. (found in 
>>http://cocoon.zones.apache.org/demos/release/docs/userdocs/generators/directory-generator.html)
>><map:match pattern="my*">
>>   <map:generate src="my"/>
>>   </map:match>
>>    
>>
>
>That is not what the page tells you to do.
>Anyway, see below.
>
>  
>
ok, I used exact syntax from the page
<map:match pattern="my">
<map:generate type="directory" src="my">
    <map:parameter name="depth" value="2"/>
  </map:generate>    
   </map:match>

, added section into sitemap.xmap
<map:generators>
<map:generator name="directory"
    src="org.apache.cocoon.generation.DirectoryGenerator"/>
</map:generators>

used the suggestions from thorsten, the link is http://localhost:8888/my 
now, but still the same error.

>>But when I click on the link, I get 'The requested resource "/my/" could 
>>not be found.'
>>
>>    
>>
>Search the recent archives (late last month?) of the
>forrest mailing lists ("user" perhaps) where we helped
>someone to do that. It is not hard.
>
>  
>
haven't found any new documentation. ;(

Mirek

using DirectoryGenerator (Was: Using XML db as the source of xml files)

Posted by David Crossley <cr...@apache.org>.
Miroslav Mocek wrote:
> ok, I am really lost, so I tried to get first DirectoryGenerator 
> running. (should be simpler, I hope)
> 
> I wasn't successfull. What I did:
> 
> I've created subdir "my" in content/xdocs and put 2 files in it - 
> first.xml and second.xml (which are just easier versions of index.xml now)
> 
> I've put this 3 lines in my sitemap.xmap. (found in 
> http://cocoon.zones.apache.org/demos/release/docs/userdocs/generators/directory-generator.html)
> <map:match pattern="my*">
>    <map:generate src="my"/>
>    </map:match>

That is not what the page tells you to do.
Anyway, see below.

> before the
>   <map:match pattern="**.xml">
> 
> I've created element in site.xml:
> <dirLink label="myaddr" href="my/" />
> 
> And used the link in index.xml as:
> <link href="site:dirLink">link for my dir</link>.
> 
> The link is transformed as http://localhost:8888/my/ - it's ok.
> But when I click on the link, I get 'The requested resource "/my/" could 
> not be found.'
> 
> I think, my sitemap.xmap configuration is wrong. But I cannot find any 
> documentation how to do it right.
> Any suggestions?
> Thanks Mirek

Search the recent archives (late last month?) of the
forrest mailing lists ("user" perhaps) where we helped
someone to do that. It is not hard.

We should create a demo in the "seed-sample" site.

-David

Re: Using XML db as the source of xml files

Posted by Miroslav Mocek <mm...@seznam.cz>.
ok, I am really lost, so I tried to get first DirectoryGenerator 
running. (should be simpler, I hope)

I wasn't successfull. What I did:

I've created subdir "my" in content/xdocs and put 2 files in it - 
first.xml and second.xml (which are just easier versions of index.xml now)

I've put this 3 lines in my sitemap.xmap. (found in 
http://cocoon.zones.apache.org/demos/release/docs/userdocs/generators/directory-generator.html)
<map:match pattern="my*">
    <map:generate src="my"/>
    </map:match>

before the
   <map:match pattern="**.xml">

I've created element in site.xml:
<dirLink label="myaddr" href="my/" />

And used the link in index.xml as:
<link href="site:dirLink">link for my dir</link>.

The link is transformed as http://localhost:8888/my/ - it's ok.
But when I click on the link, I get 'The requested resource "/my/" could 
not be found.'

I think, my sitemap.xmap configuration is wrong. But I cannot find any 
documentation how to do it right.
Any suggestions?
Thanks Mirek


Ross Gardler wrote:

> Miroslav Mocek wrote:
>
>> Hello,
>>
>> I have a set of XML files (in my own vocabulary) in some directory 
>> structure. I was thinking of generating my site from the files. (I 
>> would definitely need the recursing directory approach, because there 
>> is a lot of files and it will be dynamic archive. As stated in user 
>> maillist - 'create a custom sitemap entry that uses the 
>> DirectoryGenerator from Cocoon'. Well, I'm not quite sure, how to get 
>> that working...)
>>
>> But now I'm thinking about converting the whole directory structure 
>> with files into native XML db (xindice - or do you know better? I am 
>> really new in this topic). And use forrest to generate the site from 
>> the XML db.
>> Is THAT possible? As I read documentation, it could be. Forrest 
>> documentation says: 'one can - Read content from exotic sources like 
>> XML databases'. Had someone already tried that?
>
>
> Yes, it is possible. How you do it depends on the interfaces made 
> available by your chosen database.
>
> If there is an http api then you can simply use the locationmap in 
> 0.8-dev, or a custom sitemap in 0.7
>
> If there is no http api you will need a Cocoon generator to read the 
> files from the DB (this will, most likely, be faster than the 
> locationmap/sitemap technique too).
>
> Cocoon has an XML:DB block, you can probably leverage that [1]
>
> Ross
>
> [1] 
> http://cocoon.zones.apache.org/demos/release/samples/blocks/xmldb/welcome
>


Re: Using XML db as the source of xml files

Posted by Ross Gardler <rg...@apache.org>.
Miroslav Mocek wrote:
> Hello,
> 
> I have a set of XML files (in my own vocabulary) in some directory 
> structure. I was thinking of generating my site from the files. (I would 
> definitely need the recursing directory approach, because there is a lot 
> of files and it will be dynamic archive. As stated in user maillist - 
> 'create a custom sitemap entry that uses the DirectoryGenerator from 
> Cocoon'. Well, I'm not quite sure, how to get that working...)
> 
> But now I'm thinking about converting the whole directory structure with 
> files into native XML db (xindice - or do you know better? I am really 
> new in this topic). And use forrest to generate the site from the XML db.
> Is THAT possible? As I read documentation, it could be. Forrest 
> documentation says: 'one can - Read content from exotic sources like XML 
> databases'. Had someone already tried that?

Yes, it is possible. How you do it depends on the interfaces made 
available by your chosen database.

If there is an http api then you can simply use the locationmap in 
0.8-dev, or a custom sitemap in 0.7

If there is no http api you will need a Cocoon generator to read the 
files from the DB (this will, most likely, be faster than the 
locationmap/sitemap technique too).

Cocoon has an XML:DB block, you can probably leverage that [1]

Ross

[1] 
http://cocoon.zones.apache.org/demos/release/samples/blocks/xmldb/welcome