You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Martin Holmes <mh...@uvic.ca> on 2009/01/20 01:09:20 UTC

Determining the host OS

HI folks,

I'm trying to write a Cocoon-2.1-based application which I want to be 
completely portable between Tomcats running on Linux, OSX and Windows. 
I'm having a problem with the use of slashes and backslashes, especially 
on Windows, where I've found that some relative paths are expressed with 
backslashes and some with forward slashes, and the {realpath:/} constant 
returns a value without a trailing slash (whereas on *nix there seems to 
always be a trailing slash.

I could solve these problems using Flowscript and XSLT if I could 
determine what host OS Cocoon is running on. However, I can't find a way 
to do that in the sitemap. There's the HostSelector, which tells me the 
domain of the host; and there's the BrowserSelector, which tells me the 
connecting client's browser; but there's no way I can find to discover 
what operating system Cocoon is running on.

Does anyone know a way to do this, preferably directly in the sitemap?

All help appreciated,
Martin


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


Re: Determining the host OS

Posted by Martin Holmes <mh...@uvic.ca>.
That does help, for sure; it's quicker to know which slash to add when I 
need to add one. I'd love to be sure that the absence of the trailing 
slash was reliable on Windows, and its presence reliable on *nix, but it 
seems better to check.

Cheers,
Martin

Robin Rigby wrote:
> Martin
> 
> Does this help you?
> 
> <map:parameter name="system-property:file.separator"
> value="{system-property:file.separator}"/>
> 
> Look at
> 
> blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF
> /modules/sitemap.xmap 
> 
> 
>  
> Robin 
>  
> 
> -----Original Message-----
> From: news [mailto:news@ger.gmane.org] On Behalf Of Martin Holmes
> Sent: 20 January 2009 16:49
> To: users@cocoon.apache.org
> Subject: Re: Determining the host OS
> 
> HI Steve,
> 
> Do you know how to call this in a sitemap? If I pass this into an XSLT 
> transformation:
> 
> <map:parameter name="osName" value="{system-property:os.name}" />
> 
> the parameter is empty.
> 
> Cheers,
> Martin
> 
> Stephen Winnall wrote:
>> There is a module called SystemPropertyModule which appears to do what 
>> you want. Just ask it for "os.name".
>>
>> Steve
>>
>> On 20 Jan 2009, at 01:09, Martin Holmes wrote:
>>
>>> HI folks,
>>>
>>> I'm trying to write a Cocoon-2.1-based application which I want to be 
>>> completely portable between Tomcats running on Linux, OSX and Windows. 
>>> I'm having a problem with the use of slashes and backslashes, 
>>> especially on Windows, where I've found that some relative paths are 
>>> expressed with backslashes and some with forward slashes, and the 
>>> {realpath:/} constant returns a value without a trailing slash 
>>> (whereas on *nix there seems to always be a trailing slash.
>>>
>>> I could solve these problems using Flowscript and XSLT if I could 
>>> determine what host OS Cocoon is running on. However, I can't find a 
>>> way to do that in the sitemap. There's the HostSelector, which tells 
>>> me the domain of the host; and there's the BrowserSelector, which 
>>> tells me the connecting client's browser; but there's no way I can 
>>> find to discover what operating system Cocoon is running on.
>>>
>>> Does anyone know a way to do this, preferably directly in the sitemap?
>>>
>>> All help appreciated,
>>> Martin
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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


RE: Determining the host OS

Posted by Robin Rigby <ro...@gondolier.org.uk>.
Martin

Does this help you?

<map:parameter name="system-property:file.separator"
value="{system-property:file.separator}"/>

Look at

blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF
/modules/sitemap.xmap 


 
Robin 
 

-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Martin Holmes
Sent: 20 January 2009 16:49
To: users@cocoon.apache.org
Subject: Re: Determining the host OS

HI Steve,

Do you know how to call this in a sitemap? If I pass this into an XSLT 
transformation:

<map:parameter name="osName" value="{system-property:os.name}" />

the parameter is empty.

Cheers,
Martin

Stephen Winnall wrote:
> There is a module called SystemPropertyModule which appears to do what 
> you want. Just ask it for "os.name".
> 
> Steve
> 
> On 20 Jan 2009, at 01:09, Martin Holmes wrote:
> 
>> HI folks,
>>
>> I'm trying to write a Cocoon-2.1-based application which I want to be 
>> completely portable between Tomcats running on Linux, OSX and Windows. 
>> I'm having a problem with the use of slashes and backslashes, 
>> especially on Windows, where I've found that some relative paths are 
>> expressed with backslashes and some with forward slashes, and the 
>> {realpath:/} constant returns a value without a trailing slash 
>> (whereas on *nix there seems to always be a trailing slash.
>>
>> I could solve these problems using Flowscript and XSLT if I could 
>> determine what host OS Cocoon is running on. However, I can't find a 
>> way to do that in the sitemap. There's the HostSelector, which tells 
>> me the domain of the host; and there's the BrowserSelector, which 
>> tells me the connecting client's browser; but there's no way I can 
>> find to discover what operating system Cocoon is running on.
>>
>> Does anyone know a way to do this, preferably directly in the sitemap?
>>
>> All help appreciated,
>> Martin
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>


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




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


Re: Determining the host OS

Posted by Martin Holmes <mh...@uvic.ca>.
My mistake here: I'd added it to one matcher, but I was looking for it 
in the output of another one. It works just fine!

Thanks indeed.

Cheers,
Martin

Andy Stevens wrote:
> 2009/1/20 Martin Holmes <mh...@uvic.ca>:
>> HI Steve,
>>
>> Do you know how to call this in a sitemap? If I pass this into an XSLT
>> transformation:
>>
>> <map:parameter name="osName" value="{system-property:os.name}" />
>>
>> the parameter is empty.
> 
> That looks reasonable to me.  I assume you've got the input module
> defined somewhere? (either in the components section of the sitemap
> or, more likely, the default
> <component-instance
> class="org.apache.cocoon.components.modules.input.SystemPropertyModule"
> logger="core.modules.input" name="system-property"/>
> entry in cocoon.xconf)
> Chances are it would throw an error anyway if it wasn't.
> 
> What if you try
> <map:parameter name="osName" value="testing-{system-property:os.name}" />
> ?  Is the parameter still empty in your XSL?  If so, it's not the
> input module bit that's the problem.  What does the start of your XSL
> file (especially the xsl:param) look like?
> 
> The system-property module is a jxpath-based one; I know the example
> on http://cocoon.apache.org/2.1/userdocs/concepts/modules.html uses
> {system-property:substring-before(user.home, user.name)}
> but I'd have thought it should still be okay with no functions.  Do
> any other system properties work?  Perhaps the app server hides some
> of them - if you write a JSP that loops over them all and prints them
> out, is os.name included in the list?  Are you getting any
> securitymanager errors appearing in the logs?
> 
> Some more ideas at least.
> 
> 
> Andy


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


Re: Determining the host OS

Posted by Andy Stevens <in...@googlemail.com>.
2009/1/20 Martin Holmes <mh...@uvic.ca>:
> HI Steve,
>
> Do you know how to call this in a sitemap? If I pass this into an XSLT
> transformation:
>
> <map:parameter name="osName" value="{system-property:os.name}" />
>
> the parameter is empty.

That looks reasonable to me.  I assume you've got the input module
defined somewhere? (either in the components section of the sitemap
or, more likely, the default
<component-instance
class="org.apache.cocoon.components.modules.input.SystemPropertyModule"
logger="core.modules.input" name="system-property"/>
entry in cocoon.xconf)
Chances are it would throw an error anyway if it wasn't.

What if you try
<map:parameter name="osName" value="testing-{system-property:os.name}" />
?  Is the parameter still empty in your XSL?  If so, it's not the
input module bit that's the problem.  What does the start of your XSL
file (especially the xsl:param) look like?

The system-property module is a jxpath-based one; I know the example
on http://cocoon.apache.org/2.1/userdocs/concepts/modules.html uses
{system-property:substring-before(user.home, user.name)}
but I'd have thought it should still be okay with no functions.  Do
any other system properties work?  Perhaps the app server hides some
of them - if you write a JSP that loops over them all and prints them
out, is os.name included in the list?  Are you getting any
securitymanager errors appearing in the logs?

Some more ideas at least.


Andy
-- 
http://pseudoq.sourceforge.net/

>
> Cheers,
> Martin
>
> Stephen Winnall wrote:
>>
>> There is a module called SystemPropertyModule which appears to do what you
>> want. Just ask it for "os.name".
>>
>> Steve
>>
>> On 20 Jan 2009, at 01:09, Martin Holmes wrote:
>>
>>> HI folks,
>>>
>>> I'm trying to write a Cocoon-2.1-based application which I want to be
>>> completely portable between Tomcats running on Linux, OSX and Windows. I'm
>>> having a problem with the use of slashes and backslashes, especially on
>>> Windows, where I've found that some relative paths are expressed with
>>> backslashes and some with forward slashes, and the {realpath:/} constant
>>> returns a value without a trailing slash (whereas on *nix there seems to
>>> always be a trailing slash.
>>>
>>> I could solve these problems using Flowscript and XSLT if I could
>>> determine what host OS Cocoon is running on. However, I can't find a way to
>>> do that in the sitemap. There's the HostSelector, which tells me the domain
>>> of the host; and there's the BrowserSelector, which tells me the connecting
>>> client's browser; but there's no way I can find to discover what operating
>>> system Cocoon is running on.
>>>
>>> Does anyone know a way to do this, preferably directly in the sitemap?
>>>
>>> All help appreciated,
>>> Martin

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


Re: Determining the host OS

Posted by Martin Holmes <mh...@uvic.ca>.
HI Steve,

Do you know how to call this in a sitemap? If I pass this into an XSLT 
transformation:

<map:parameter name="osName" value="{system-property:os.name}" />

the parameter is empty.

Cheers,
Martin

Stephen Winnall wrote:
> There is a module called SystemPropertyModule which appears to do what 
> you want. Just ask it for "os.name".
> 
> Steve
> 
> On 20 Jan 2009, at 01:09, Martin Holmes wrote:
> 
>> HI folks,
>>
>> I'm trying to write a Cocoon-2.1-based application which I want to be 
>> completely portable between Tomcats running on Linux, OSX and Windows. 
>> I'm having a problem with the use of slashes and backslashes, 
>> especially on Windows, where I've found that some relative paths are 
>> expressed with backslashes and some with forward slashes, and the 
>> {realpath:/} constant returns a value without a trailing slash 
>> (whereas on *nix there seems to always be a trailing slash.
>>
>> I could solve these problems using Flowscript and XSLT if I could 
>> determine what host OS Cocoon is running on. However, I can't find a 
>> way to do that in the sitemap. There's the HostSelector, which tells 
>> me the domain of the host; and there's the BrowserSelector, which 
>> tells me the connecting client's browser; but there's no way I can 
>> find to discover what operating system Cocoon is running on.
>>
>> Does anyone know a way to do this, preferably directly in the sitemap?
>>
>> All help appreciated,
>> Martin
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>


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


Re: Determining the host OS

Posted by Stephen Winnall <st...@winnall.ch>.
There is a module called SystemPropertyModule which appears to do what  
you want. Just ask it for "os.name".

Steve

On 20 Jan 2009, at 01:09, Martin Holmes wrote:

> HI folks,
>
> I'm trying to write a Cocoon-2.1-based application which I want to  
> be completely portable between Tomcats running on Linux, OSX and  
> Windows. I'm having a problem with the use of slashes and  
> backslashes, especially on Windows, where I've found that some  
> relative paths are expressed with backslashes and some with forward  
> slashes, and the {realpath:/} constant returns a value without a  
> trailing slash (whereas on *nix there seems to always be a trailing  
> slash.
>
> I could solve these problems using Flowscript and XSLT if I could  
> determine what host OS Cocoon is running on. However, I can't find a  
> way to do that in the sitemap. There's the HostSelector, which tells  
> me the domain of the host; and there's the BrowserSelector, which  
> tells me the connecting client's browser; but there's no way I can  
> find to discover what operating system Cocoon is running on.
>
> Does anyone know a way to do this, preferably directly in the sitemap?
>
> All help appreciated,
> Martin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


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