You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2007/07/18 14:35:58 UTC

Namespace: behaviour differences

I am getting strange problems on the production machine vs the test
behaviour on my PC.
 
A query like this:
<?xml version="1.0" encoding="UTF-8"?>
<page
  xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
 xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
>
  <sq2:execute-query> 
    <sq2:query name="program-view">
       select  * from client
    </sq2:query>
  </sq2:execute-query>
</page> 

results in this output locally:
 <?xml version="1.0" encoding="UTF-8" ?> 
 <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
   <sq2:rowset nrofrows="1" name="client-view">
 
but on the server I get:

<?xml version="1.0" encoding="UTF-8" ?> 
 <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> 
 <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="1"
name="client-view">
  
and as a consequence, the stylesheets do not function, as they are
looking for the sq2: prefix.

How do ensure that Cocoon on the server retains the sq2: prefix.... 
and why does it strip it off in the first place?

Thanks
Derek

 
 
 





-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: Namespace: behaviour differences

Posted by Tobia Conforto <to...@linux.it>.
Let's recap.  The following two statements are equivalent and are both
prefix-independent:

<xsl:apply-templates select="sq2:rowset[@name = 'program-view']"/>

<xsl:apply-templates select="*[local-name() = 'rowset'
	and namespace-uri() = 'http://apache.org/cocoon/SQL/2.0'
	and @name = 'program-view']"/>

The only way to make an XPath expression prefix-dependant (which is
usually bad) is to use the name() function.  Thus the name() function
should be avoided whenever possible, using local-name() in its stead,
or better yet direct expressions such as self::sq2:rowset.

The two statements above should apply to both XML files (which are two
equivalent forms of the same XML data) yielding the same results.

The former statement is preferable, since it's shorter, it's more easily
optimizable (as somebody else pointed out) and you are defining the SQL2
namespace only once, but they should both work on both XML files.

Indeed they do: I just tested all four combinations with xsltproc and
the result is always the same, with both "found page" and "found rowset"


It looks like something is broken in your server installation.


Tobia

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


Re: Namespace: behaviour differences

Posted by Joerg Heinicke <jo...@gmx.de>.
On 20.07.2007 04:43, Derek Hohls wrote:

> This stylesheet works fine with BOTH pages on the PC; but only works 
> on the first page when running on the server i.e. it produces the
>   <tr><td>found page</td></tr>
> output, but does not display the rowset match.
>  
> What are the next options available to solve this problem?

Have you ever heard of the endorsed libs problem [1]? Try to find out 
which versions of the XML libs you are running on both machines using 
the environment check stylesheet as explained at [2].

Joerg

[1] http://wiki.apache.org/cocoon/EndorsedLibsProblem
[2] http://wiki.apache.org/cocoon/NoMoreDtmIdError

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


Re: Namespace: behaviour differences

Posted by Derek Hohls <DH...@csir.co.za>.
Suzan
 
Thanks - but this is just a simple example to illustrate the point.
In real life, the logic is more complex.... :)
It seems that the real problem is with the Cocoon installation on
the server and/or the java version.  Sigh.
 
Derek

>>> Suzan Foster <su...@nerocmediaware.nl> 2007/07/20 02:49 PM
>>>

Derek Hohls schreef:
> <xsl:template match="page">
>   <tr><td>found page</td></tr>
>   <xsl:apply-templates select="*[local-name()='rowset' and
> @name='program-view' and
> namespace-uri()='http://apache.org/cocoon/SQL/2.0']"/>
> </xsl:template>
>  
> <xsl:template match="sq2:rowset[@name='program-view']">
>   <tr><td>found rowset</td></tr>
> </xsl:template> 

The select in your apply-templates isn't necessarry. The matcher on the

template already defines what will be output. The following should be 
sufficient:

<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sq2="http://apache.org/cocoon/SQL/2.0">

    <xsl:template match="page">
        <tr><td>found page</td></tr>
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="sq2:rowset[@name='program-view']">
        <tr><td>found rowset</td></tr>
    </xsl:template>

</xsl:stylesheet>


Regards,
Suzan Foster.

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



-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: Namespace: behaviour differences

Posted by Suzan Foster <su...@nerocmediaware.nl>.
Derek Hohls schreef:
> <xsl:template match="page">
>   <tr><td>found page</td></tr>
>   <xsl:apply-templates select="*[local-name()='rowset' and
> @name='program-view' and
> namespace-uri()='http://apache.org/cocoon/SQL/2.0']"/>
> </xsl:template>
>  
> <xsl:template match="sq2:rowset[@name='program-view']">
>   <tr><td>found rowset</td></tr>
> </xsl:template> 

The select in your apply-templates isn't necessarry. The matcher on the 
template already defines what will be output. The following should be 
sufficient:

<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sq2="http://apache.org/cocoon/SQL/2.0">

    <xsl:template match="page">
        <tr><td>found page</td></tr>
        <xsl:apply-templates/>
    </xsl:template>
 
    <xsl:template match="sq2:rowset[@name='program-view']">
        <tr><td>found rowset</td></tr>
    </xsl:template>

</xsl:stylesheet>


Regards,
Suzan Foster.

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


Re: Namespace: behaviour differences

Posted by Derek Hohls <DH...@csir.co.za>.
My namespace woes continue...
 
I have now created two test XML pages.  One represents the 
XML output from the SQL Transformer on the PC, and looks like:
 
<?xml version="1.0" encoding="UTF-8" ?> 
<page xmlns:sq2="http://apache.org/cocoon/SQL/2.0">
 <sq2:rowset nrofrows="1" name="program-view">
  <sq2:row>
   <sq2:programid>TEST01</sq2:programid> 
 </sq2:row>
 </sq2:rowset>
</page>
 
and a second one, representing output from the server
which looks like:
 
<?xml version="1.0" encoding="UTF-8" ?> 
<page xmlns:sq2="http://apache.org/cocoon/SQL/2.0">
 <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="1"
name="program-view">
  <row>
   <programid>TEST01</programid> 
 </row>
 </rowset>
</page>
 
The stylesheet was modified to use local-name() and 
namespace-uri() functions which is supposed to make
it independent of whether or not a prefix is found.
and looks like this:
 
<xsl:stylesheet 
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
  >
 
<xsl:template match="/">
<page>
  <xsl:apply-templates select="page"/>
</page>
</xsl:template>
 
<xsl:template match="page">
  <tr><td>found page</td></tr>
  <xsl:apply-templates select="*[local-name()='rowset' and
@name='program-view' and
namespace-uri()='http://apache.org/cocoon/SQL/2.0']"/>
</xsl:template>
 
<xsl:template match="sq2:rowset[@name='program-view']">
  <tr><td>found rowset</td></tr>
</xsl:template> 
 
</xsl:stylesheet>
 

This stylesheet works fine with BOTH pages on the PC; but only works 
on the first page when running on the server i.e. it produces the
  <tr><td>found page</td></tr>
output, but does not display the rowset match.
 
What are the next options available to solve this problem?
 
Thanks
Derek


>>> Grzegorz Kossakowski <gk...@apache.org> 2007/07/18 07:06 PM
>>>

Derek Hohls pisze:
> Grzegorz 
>  
> Thanks for the kind offer.  Attached is a simple example.

No problem. Derek, I've taken a look at your stylesheet and I see no
reliance on prefix in there. If you use construct like this:

   <xsl:apply-templates select="sq2:rowset[@name='program-view']"/>

it does not imply that you want to select tags with name "sq2:rowset"
but it means you want to select all tags with local name "rowest" in 
namespace with sq2 prefix defined in the _styleshet_:

   <xsl:stylesheet
   version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:sq2="http://apache.org/cocoon/SQL/2.0">

Your select is exactly equivalent to:

   select="*[local-name() = 'rowset' and namespace-uri() =
'http://apache.org/cocoon/SQL/2.0' and @name='program-view']"

For description of used functions consult XPath specification:
http://www.w3.org/TR/xpath#section-Node-Set-Functions 

As you see, there is no dependency on sq2 prefix that you define
locally in all XML documents (including XSL stylesheets).

I hope that helps you a little.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/ 


-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: Namespace: behaviour differences

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Derek Hohls pisze:
> Grzegorz
>  
> Thanks for the reply.
>  
> Up to now I have never had this problem.  If you write your stylesheets
> in the
> manner you describe, perhaps you can post a small code snippet that
> shows
> how this can be achieved (and I have not seen it described elsewhere).

Derek, I think it will be easier for me to take a look at your stylesheets and see what you want to achieve. Afterwards, I could give you an 
advice how to do the same but in prefix-independent way.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

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


Re: Namespace: behaviour differences

Posted by Derek Hohls <DH...@csir.co.za>.
Grzegorz
 
Thanks for the reply.
 
Up to now I have never had this problem.  If you write your stylesheets
in the
manner you describe, perhaps you can post a small code snippet that
shows
how this can be achieved (and I have not seen it described elsewhere).
 
Thanks
Derek

>>> Grzegorz Kossakowski <gk...@apache.org> 2007/07/18 02:50 PM
>>>

Derek Hohls pisze:
> I am getting strange problems on the production machine vs the test
> behaviour on my PC.
>  
> A query like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <page
>   xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
>  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
>   <sq2:execute-query> 
>     <sq2:query name="program-view">
>        select  * from client
>     </sq2:query>
>   </sq2:execute-query>
> </page> 
> 
> results in this output locally:
>  <?xml version="1.0" encoding="UTF-8" ?> 
>  <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>    <sq2:rowset nrofrows="1" name="client-view">
>  
> but on the server I get:
> 
> <?xml version="1.0" encoding="UTF-8" ?> 
>  <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> 
>  <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="1"
> name="client-view">
>   
> and as a consequence, the stylesheets do not function, as they are
> looking for the sq2: prefix.
> 
> How do ensure that Cocoon on the server retains the sq2: prefix.... 
> and why does it strip it off in the first place?

I don't know why do you experience such differences but I would like to
point out that both XML snippets are  equivalent in terms defined in 
XML spec. In short: you should never rely on namespace prefix because
it's only a shorthand that can vary.

Before you try to discover the roots of this behaviour I would suggest
you to try rewrite your stylesheets to be prefix-independent.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/ 

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



-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


RE: Namespace: behaviour differences

Posted by Robin Rigby <ro...@gondolier.org.uk>.
Thanks.  That is how I understood it.  I had not seen the term
'prefix-independent' before. 


 
Robin Rigby
robin@gondolier.org.uk
http://www.gondolier.org.uk
07785 765017
 

-----Original Message-----
From: Grzegorz Kossakowski [mailto:gkossakowski@apache.org] 
Sent: 18 July 2007 19:32
To: users@cocoon.apache.org
Subject: Re: Namespace: behaviour differences

Robin Rigby pisze:
> Grzegorz
> 
> Can you recommend a tutorial or other info for prefix-independent XSLT?

I'm not sure if such tutorial would exist because if you write stylesheets
using standard techniques they are prefix-independent. You make 
your stylesheet relying on namespace prefix if you use name()[1] function
instead of local-name()[2].

Even if you reference elements in stylesheet using prefix it's defined in
that stylesheet _locally_. It means that you could use different 
prefixes (pointing to the same namespace, of course) in processed XML and
XSL stylesheet and it should work.

I think it's crucial to understand that prefix is defined locally and is not
part of element's name but only element's expanded name.

[1] http://www.w3.org/TR/xpath#function-name
[2] http://www.w3.org/TR/xpath#function-local-name

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
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: Namespace: behaviour differences

Posted by Baptiste Placé <bo...@free.fr>.
Derek,

Maybe you should dig deeper in this magic faq :)
I found the last question [1] interesting :
It is about determining the prefix used in the source document, you may 
be able to stock the sql prefix in a variable and use it in your match.

Baptiste

[1] http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e2485

Derek Hohls a écrit :
> Baptiste
>  
> Interestingly, one of the examples on identifying elements by
> namespace, where there is more than one namespace present,
> is written by Jeni Tennison, who is certainly one of the gurus of
> XSLT - she simply uses prefixes in this example:
> http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e1096 
> (just as well she is not working with Cocoon!)
>
> and this example:
> http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e655 
> by David Carlisle also suggests using prefixes in the source
> document to ensure a stylesheet works - which we cannot
> do because we seemingly have no control over how the SQL
> Transformer creates the output (ito of keeping prefixes)
>  
> So... no joy yet ito practical examples, but I will look as and 
> when I have time....  if anyone else has a link to specific 
> examples, I would appreciate it.
>
>   
>>>> Baptiste Placé <bo...@free.fr> 2007/07/19 09:46 AM >>>
>>>>         
>
> Hello,
>
> You may find more examples on the issue on XSLT Questions and Answers [1].
> Great resource for XSLT, it may help.
>
> Baptiste.
>
> [1] http://www.dpawson.co.uk/xsl/sect2/sect21.html 
>
> Derek Hohls a écrit :
>   
>> Grzegorz 
>>  
>> OK; maybe that is what I was asking - where are these "standard
>> techniques" -
>> I have not come across any such examples in my years of working with
>> XSLT
>> and have never before had problems of the sort that are happening now.
>> Any pointers, apart from those to the spec (which is not an easy
>> document at the
>> best of times ;-)
>>  
>> Derek
>>
>>   
>>     
>>>>> Grzegorz Kossakowski <gk...@apache.org> 2007/07/18 08:31 PM
>>>>>
>>>>>         
>>>>>           
>> Robin Rigby pisze:
>>   
>>     
>>> Grzegorz
>>>
>>> Can you recommend a tutorial or other info for prefix-independent
>>>     
>>>       
>> XSLT?
>>
>> I'm not sure if such tutorial would exist because if you write
>> stylesheets using standard techniques they are prefix-independent. You
>> make 
>> your stylesheet relying on namespace prefix if you use name()[1]
>> function instead of local-name()[2].
>>
>> Even if you reference elements in stylesheet using prefix it's defined
>> in that stylesheet _locally_. It means that you could use different 
>> prefixes (pointing to the same namespace, of course) in processed XML
>> and XSL stylesheet and it should work.
>>
>> I think it's crucial to understand that prefix is defined locally and
>> is not part of element's name but only element's expanded name.
>>
>> [1] http://www.w3.org/TR/xpath#function-name 
>> [2] http://www.w3.org/TR/xpath#function-local-name 
>>
>>   
>>     
>
> ---------------------------------------------------------------------
> 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: Namespace: behaviour differences

Posted by Derek Hohls <DH...@csir.co.za>.
Baptiste
 
Interestingly, one of the examples on identifying elements by
namespace, where there is more than one namespace present,
is written by Jeni Tennison, who is certainly one of the gurus of
XSLT - she simply uses prefixes in this example:
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e1096 
(just as well she is not working with Cocoon!)

and this example:
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e655 
by David Carlisle also suggests using prefixes in the source
document to ensure a stylesheet works - which we cannot
do because we seemingly have no control over how the SQL
Transformer creates the output (ito of keeping prefixes)
 
So... no joy yet ito practical examples, but I will look as and 
when I have time....  if anyone else has a link to specific 
examples, I would appreciate it.

>>> Baptiste Placé <bo...@free.fr> 2007/07/19 09:46 AM >>>

Hello,

You may find more examples on the issue on XSLT Questions and Answers [1].
Great resource for XSLT, it may help.

Baptiste.

[1] http://www.dpawson.co.uk/xsl/sect2/sect21.html 

Derek Hohls a écrit :
> Grzegorz 
>  
> OK; maybe that is what I was asking - where are these "standard
> techniques" -
> I have not come across any such examples in my years of working with
> XSLT
> and have never before had problems of the sort that are happening now.
> Any pointers, apart from those to the spec (which is not an easy
> document at the
> best of times ;-)
>  
> Derek
>
>   
>>>> Grzegorz Kossakowski <gk...@apache.org> 2007/07/18 08:31 PM
>>>>
>>>>         
>
> Robin Rigby pisze:
>   
>> Grzegorz
>>
>> Can you recommend a tutorial or other info for prefix-independent
>>     
> XSLT?
>
> I'm not sure if such tutorial would exist because if you write
> stylesheets using standard techniques they are prefix-independent. You
> make 
> your stylesheet relying on namespace prefix if you use name()[1]
> function instead of local-name()[2].
>
> Even if you reference elements in stylesheet using prefix it's defined
> in that stylesheet _locally_. It means that you could use different 
> prefixes (pointing to the same namespace, of course) in processed XML
> and XSL stylesheet and it should work.
>
> I think it's crucial to understand that prefix is defined locally and
> is not part of element's name but only element's expanded name.
>
> [1] http://www.w3.org/TR/xpath#function-name 
> [2] http://www.w3.org/TR/xpath#function-local-name 
>
>   

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




-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: Namespace: behaviour differences

Posted by Baptiste Placé <bo...@free.fr>.
Hello,

You may find more examples on the issue on XSLT Questions and Answers [1].
Great resource for XSLT, it may help.

Baptiste.

[1] http://www.dpawson.co.uk/xsl/sect2/sect21.html

Derek Hohls a écrit :
> Grzegorz 
>  
> OK; maybe that is what I was asking - where are these "standard
> techniques" -
> I have not come across any such examples in my years of working with
> XSLT
> and have never before had problems of the sort that are happening now.
> Any pointers, apart from those to the spec (which is not an easy
> document at the
> best of times ;-)
>  
> Derek
>
>   
>>>> Grzegorz Kossakowski <gk...@apache.org> 2007/07/18 08:31 PM
>>>>
>>>>         
>
> Robin Rigby pisze:
>   
>> Grzegorz
>>
>> Can you recommend a tutorial or other info for prefix-independent
>>     
> XSLT?
>
> I'm not sure if such tutorial would exist because if you write
> stylesheets using standard techniques they are prefix-independent. You
> make 
> your stylesheet relying on namespace prefix if you use name()[1]
> function instead of local-name()[2].
>
> Even if you reference elements in stylesheet using prefix it's defined
> in that stylesheet _locally_. It means that you could use different 
> prefixes (pointing to the same namespace, of course) in processed XML
> and XSL stylesheet and it should work.
>
> I think it's crucial to understand that prefix is defined locally and
> is not part of element's name but only element's expanded name.
>
> [1] http://www.w3.org/TR/xpath#function-name 
> [2] http://www.w3.org/TR/xpath#function-local-name 
>
>   

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


Re: Namespace: behaviour differences

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Derek Hohls pisze:
> Grzegorz 
>  
> OK; maybe that is what I was asking - where are these "standard
> techniques" -
> I have not come across any such examples in my years of working with
> XSLT
> and have never before had problems of the sort that are happening now.
> Any pointers, apart from those to the spec (which is not an easy
> document at the
> best of times ;-)

Derek, I must disappoint you - I've learned XSLT from spec mainly so can't help you much.
I'm sure others will give you worth-reading pointers.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

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


Re: Namespace: behaviour differences

Posted by Derek Hohls <DH...@csir.co.za>.
Grzegorz 
 
OK; maybe that is what I was asking - where are these "standard
techniques" -
I have not come across any such examples in my years of working with
XSLT
and have never before had problems of the sort that are happening now.
Any pointers, apart from those to the spec (which is not an easy
document at the
best of times ;-)
 
Derek

>>> Grzegorz Kossakowski <gk...@apache.org> 2007/07/18 08:31 PM
>>>

Robin Rigby pisze:
> Grzegorz
> 
> Can you recommend a tutorial or other info for prefix-independent
XSLT?

I'm not sure if such tutorial would exist because if you write
stylesheets using standard techniques they are prefix-independent. You
make 
your stylesheet relying on namespace prefix if you use name()[1]
function instead of local-name()[2].

Even if you reference elements in stylesheet using prefix it's defined
in that stylesheet _locally_. It means that you could use different 
prefixes (pointing to the same namespace, of course) in processed XML
and XSL stylesheet and it should work.

I think it's crucial to understand that prefix is defined locally and
is not part of element's name but only element's expanded name.

[1] http://www.w3.org/TR/xpath#function-name 
[2] http://www.w3.org/TR/xpath#function-local-name 

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/ 

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



-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: Namespace: behaviour differences

Posted by Suzan Foster <su...@nerocmediaware.nl>.
Tobia Conforto schreef:
> Here's an interesting question: is one of the following more efficient
> than the other?
>
> <xsl:value-of select="//wh:thing" xmlns:wh="http://whatever"/>
>
> <xsl:value-of select="//*[local-name() = 'thing' and namespace-uri() = 'http://whatever']"/>
>
> I'm talking about runtime efficiency, not compilation speed (assuming
> stylesheets are compiled in some way, which I believe is the case.)
>   

The first is more efficient. The second has to evaluate twice.

Regards,
Suzan Foster.

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


Re: Namespace: behaviour differences

Posted by Tobia Conforto <to...@linux.it>.
Here's an interesting question: is one of the following more efficient
than the other?

<xsl:value-of select="//wh:thing" xmlns:wh="http://whatever"/>

<xsl:value-of select="//*[local-name() = 'thing' and namespace-uri() = 'http://whatever']"/>

I'm talking about runtime efficiency, not compilation speed (assuming
stylesheets are compiled in some way, which I believe is the case.)


Tobia

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


Re: Namespace: behaviour differences

Posted by Derek Hohls <DH...@csir.co.za>.
or, I assume, use the syntax that Grzegorz provided, which does *not*
require the use of a prefix (but does, of course, require a
namespace):
 
select="*[local-name()='rowset' and
namespace-uri()='http://apache.org/cocoon/SQL/2.0' and
@name='program-view']"
 
(Thanks to both Joerg and Grzegorz for help; I am still curious as
to the different behaviour of Cocoon on server vs PC... it does mean 
that development work is more, uh, interesting!)

>>> Joerg Heinicke <jo...@gmx.de> 2007/07/19 06:33 AM >>>

On 18.07.2007 14:31, Grzegorz Kossakowski wrote:

> Even if you reference elements in stylesheet using prefix it's
defined 
> in that stylesheet _locally_. It means that you could use different 
> prefixes (pointing to the same namespace, of course) in processed XML

> and XSL stylesheet and it should work.

There is one issue though with elements in the default namespace in the

input document that massively irritates users not used to it. You MUST

bind that default namespace to a prefix.

So <xsl:template match="rowset"> won't match on <rowset 
xmlns="http://apache.org/cocoon/SQL/2.0"> however you declare the 
default namespace in the stylesheet. You must bind 
"http://apache.org/cocoon/SQL/2.0" to a prefix like sql and match on 
"sql:rowset".

Joerg

http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e1012
http://sources.redhat.com/ml/xsl-list/2001-12/msg00526.html

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



-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


Re: Namespace: behaviour differences

Posted by Joerg Heinicke <jo...@gmx.de>.
On 18.07.2007 14:31, Grzegorz Kossakowski wrote:

> Even if you reference elements in stylesheet using prefix it's defined 
> in that stylesheet _locally_. It means that you could use different 
> prefixes (pointing to the same namespace, of course) in processed XML 
> and XSL stylesheet and it should work.

There is one issue though with elements in the default namespace in the 
input document that massively irritates users not used to it. You MUST 
bind that default namespace to a prefix.

So <xsl:template match="rowset"> won't match on <rowset 
xmlns="http://apache.org/cocoon/SQL/2.0"> however you declare the 
default namespace in the stylesheet. You must bind 
"http://apache.org/cocoon/SQL/2.0" to a prefix like sql and match on 
"sql:rowset".

Joerg

http://www.dpawson.co.uk/xsl/sect2/N5536.html#d7594e1012
http://sources.redhat.com/ml/xsl-list/2001-12/msg00526.html

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


Re: Namespace: behaviour differences

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Robin Rigby pisze:
> Grzegorz
> 
> Can you recommend a tutorial or other info for prefix-independent XSLT?

I'm not sure if such tutorial would exist because if you write stylesheets using standard techniques they are prefix-independent. You make 
your stylesheet relying on namespace prefix if you use name()[1] function instead of local-name()[2].

Even if you reference elements in stylesheet using prefix it's defined in that stylesheet _locally_. It means that you could use different 
prefixes (pointing to the same namespace, of course) in processed XML and XSL stylesheet and it should work.

I think it's crucial to understand that prefix is defined locally and is not part of element's name but only element's expanded name.

[1] http://www.w3.org/TR/xpath#function-name
[2] http://www.w3.org/TR/xpath#function-local-name

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

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


RE: Namespace: behaviour differences

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

Can you recommend a tutorial or other info for prefix-independent XSLT?

 
Robin Rigby
robin@gondolier.org.uk
http://www.gondolier.org.uk
07785 765017
 

-----Original Message-----
From: Grzegorz Kossakowski [mailto:gkossakowski@apache.org] 
Sent: 18 July 2007 13:51
To: users@cocoon.apache.org
Subject: Re: Namespace: behaviour differences

Derek Hohls pisze:
> I am getting strange problems on the production machine vs the test
> behaviour on my PC.
>  
> A query like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <page
>   xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
>  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
>   <sq2:execute-query> 
>     <sq2:query name="program-view">
>        select  * from client
>     </sq2:query>
>   </sq2:execute-query>
> </page> 
> 
> results in this output locally:
>  <?xml version="1.0" encoding="UTF-8" ?> 
>  <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>    <sq2:rowset nrofrows="1" name="client-view">
>  
> but on the server I get:
> 
> <?xml version="1.0" encoding="UTF-8" ?> 
>  <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> 
>  <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="1"
> name="client-view">
>   
> and as a consequence, the stylesheets do not function, as they are
> looking for the sq2: prefix.
> 
> How do ensure that Cocoon on the server retains the sq2: prefix.... 
> and why does it strip it off in the first place?

I don't know why do you experience such differences but I would like to
point out that both XML snippets are  equivalent in terms defined in 
XML spec. In short: you should never rely on namespace prefix because it's
only a shorthand that can vary.

Before you try to discover the roots of this behaviour I would suggest you
to try rewrite your stylesheets to be prefix-independent.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

---------------------------------------------------------------------
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: Namespace: behaviour differences

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Derek Hohls pisze:
> I am getting strange problems on the production machine vs the test
> behaviour on my PC.
>  
> A query like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <page
>   xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
>  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
>   <sq2:execute-query> 
>     <sq2:query name="program-view">
>        select  * from client
>     </sq2:query>
>   </sq2:execute-query>
> </page> 
> 
> results in this output locally:
>  <?xml version="1.0" encoding="UTF-8" ?> 
>  <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>    <sq2:rowset nrofrows="1" name="client-view">
>  
> but on the server I get:
> 
> <?xml version="1.0" encoding="UTF-8" ?> 
>  <page xmlns:sq2="http://apache.org/cocoon/SQL/2.0"
> xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> 
>  <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="1"
> name="client-view">
>   
> and as a consequence, the stylesheets do not function, as they are
> looking for the sq2: prefix.
> 
> How do ensure that Cocoon on the server retains the sq2: prefix.... 
> and why does it strip it off in the first place?

I don't know why do you experience such differences but I would like to point out that both XML snippets are  equivalent in terms defined in 
XML spec. In short: you should never rely on namespace prefix because it's only a shorthand that can vary.

Before you try to discover the roots of this behaviour I would suggest you to try rewrite your stylesheets to be prefix-independent.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

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