You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Szymon Stasik <sz...@efigence.com> on 2002/03/13 21:25:54 UTC
[C2] xslt/namespace weird problem
Hi,
I have some weird problem that seems to be cocoon/trax related. Let's
have two simple files:
bug/src.xml (should be allowed to be much more complicated):
<?xml version="1.0"?>
<root><addsql/><root>
bug/addsql.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="addsql">
<execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
<query name="file">SELECT 1 AS bug</query>
</execute-query>
</xsl:template>
<xsl:template match="@*|node()|text()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
and fragment of sitemap.xmap
<map:match pattern="bug">
<map:generate src="context://bug/src.xml"/>
<map:transform src="context://bug/addsql.xsl"/>
<map:transform type="sql">
<map:parameter name="use-connection" value="whatever"/>
</map:transform>
<map:serialize/>
</map:match>
the output is ... nothing however in the logs I can found everything up to
HttpProcessor[8180][0]/SQLTransformer$Query: EXECUTING SELECT 1
one possible fix is to add implicit
<xsl:template match="root">
<root>
<xsl:apply-templates />
</root>
</xsl:template>
but it is impossible for dynamic xml to hardcode all possible tags ;)
another problem is that while the result after fix looks quite well:
<root>
<rowset name="file">
<row>
<bug>1</bug>
</row>
</rowset>
</root>
it is almost impossible to do anything advanced with it (eg add another
xslt map:transform after sql one) since rowset has different namespace
than root - even if this cannod be seen after serialisation.
Some debbuging - <map:transform src="context://bug/debug.xsl"/> at end
with debug.xsl:
<xsl:template match="/|*">
<element name="{name(.)}"
namespace="{namespace-uri(.)}"
local="{local-name(.)}">
<xsl:apply-templates/>
</element>
</xsl:template>
shows that there seems to be a lot of problem - eg diffrent namespaces
for diffrent elements and even empty element names whit nonempty
local-names :/
<element local="" namespace="" name="">
<element local="root" namespace="" name="root">
<element local="rowset" namespace="http://apache.org/cocoon/SQL/2.0"
name="">
<element local="row" namespace="http://apache.org/cocoon/SQL/2.0" name="">
<element local="1" namespace="http://apache.org/cocoon/SQL/2.0"
name="">1</element>
</element></element></element>
I was investigating this for an hours but without any resonable ideas
and digging into even more weirdness like this.
Also please don't send messages like - 'don't use xsl:copy' or 'keep
your xsl / transformations simple'. I have found few times people
reporting similar problems but without any solutions. I've tried to use
either older and latest cvs cocoon.
here are links propably related to this problems:
http://mailman.real-time.com/pipermail/cocoon-devel/2001-July/009126.html
http://mailman.real-time.com/pipermail/cocoon-devel/2001-June/009014.html
http://www.mail-archive.com/cocoon-users@xml.apache.org/msg07324.html
http://mailman.real-time.com/pipermail/cocoon-devel/2001-April/007123.html
regards,
Szymon
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: [C2] xslt/namespace weird problem
Posted by Szymon Stasik <sz...@efigence.com>.
Stuart Roebuck wrote:
>>
>> <?xml version="1.0"?>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> <xsl:template match="addsql">
>> <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
>> <query name="file">SELECT 1 AS bug</query>
>> </execute-query>
>> </xsl:template>
>> <xsl:template match="@*|node()|text()" priority="-1">
>> <xsl:copy>
>> <xsl:apply-templates select="@*|node()"/>
>> </xsl:copy>
>> </xsl:template>
>> </xsl:stylesheet>
>
>
> The definition of XSLT states that:
>
>> node() matches any node other than an attribute node and the root node
>
>
> So this would explain the non-matching of your root node.
root means '/' not '<root>' :) it is not a problem of matching '/' node
but eg. copying it. At this stage xslt seems to work properly since
doing serialisation directly after xslt (without sql transformer)
procues xml that looks fine to my eyes - hovewer passing it to next
transformation is beeing done without serialization - so some internal
structure seems to be a problem. Anyway the xml is still passed to the
sql transformer since I can see
HttpProcessor[8180][2]/SQLTransformer$Query: EXECUTING SELECT 1
in a log file, but it outputs nothing :(
> xsl:copy, as I understand it, makes a copy of the node set matched by
> the template match. I wonder if the match on "node()" but not on "*"
> (representing an element node) means that the resulting copy of the node
> excludes the uniquely element type attributes of the node. The
> definition of xsl:copy indicates that it automatically copies the
> namespace axis of elements, but perhaps it doesn't if the element is
> matched as a node?
I've tried yours proposal to be sure, but with same result. It seems to
me as a very cocoon2 and/or trax specific problem, so help of someone
that knows well internal cocoon structure is needed.
I can do some debuging but propably I won't be able to prepare
apriopriate fix even after finding places where something goes wrong.
> This is the copy-all match I regularly use without problem in my
> stylesheets:
>
>> <xsl:template match="*|comment()|text()|node()" priority="-1">
>> <xsl:copy>
>> <xsl:copy-of select="@*" />
>> <xsl:apply-templates />
>> </xsl:copy>
>> </xsl:template>
regards,
Szymon
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: [C2] xslt/namespace weird problem
Posted by Stuart Roebuck <st...@mac.com>.
On Wednesday, March 13, 2002, at 08:25 pm, Szymon Stasik wrote:
>
> Hi,
>
>
> I have some weird problem that seems to be cocoon/trax related. Let's
> have two simple files:
>
>
> bug/src.xml (should be allowed to be much more complicated):
>
> <?xml version="1.0"?>
> <root><addsql/><root>
>
>
> bug/addsql.xsl:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="addsql">
> <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
> <query name="file">SELECT 1 AS bug</query>
> </execute-query>
> </xsl:template>
> <xsl:template match="@*|node()|text()" priority="-1">
> <xsl:copy>
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
The definition of XSLT states that:
> node() matches any node other than an attribute node and the root node
So this would explain the non-matching of your root node.
xsl:copy, as I understand it, makes a copy of the node set matched by
the template match. I wonder if the match on "node()" but not on "*"
(representing an element node) means that the resulting copy of the node
excludes the uniquely element type attributes of the node. The
definition of xsl:copy indicates that it automatically copies the
namespace axis of elements, but perhaps it doesn't if the element is
matched as a node?
This is the copy-all match I regularly use without problem in my
stylesheets:
> <xsl:template match="*|comment()|text()|node()" priority="-1">
> <xsl:copy>
> <xsl:copy-of select="@*" />
> <xsl:apply-templates />
> </xsl:copy>
> </xsl:template>
Stuart.
Public Key - 1024D/88DD65AF 2001-11-23 Stuart Roebuck (Adolos)
Key fingerprint = 89D9 E405 F8B1 9B22 0FA2 F2C1 9E57 5AB1 88DD 65AF
-------------------------------------------------------------------------
Stuart Roebuck stuart.roebuck@adolos.com
Systems Architect Java, XML, MacOS X, XP,
etc.
ADOLOS <http://www.adolos.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org