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:[EMAIL PROTECTED]'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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]'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
[EMAIL PROTECTED]
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]