Re: [Gestalt-users] Bug in namespace-uri-for-prefix() ?
Status: Alpha
Brought to you by:
colin-adams
From: Florent G. <dar...@ya...> - 2006-12-19 14:50:30
|
Colin Adams wrote: Hi Colin, > From: Florent Georges > > I've worked a little bit on XSLT Unit, and I found a > > bug (I think) related to namespace-uri-for-prefix(). I > > updated my copy of Gexslt today. Here is the test case, > > with the > BTW, you may not know that EiffelStudio 5.7 is now out of > beta - in which case you should probably upgrade A few months ago, I installed the following version: EiffelStudio 5 (5.7.62804 GPL Edition). I don't know if it is interesting to upgrade? Note I only need it for Gexslt. > > as="namespace()*", but namespace() is not a valid KindTest. > Hm. Maybe I should check the spec. - just because I don't > support the namespace axis, may not necessarily mean the > kinfd test is invalid. No, it is a well-known limitation of XPath 2.0, IMHO. The KindTest production rule is defined as: [54] KindTest ::= DocumentTest | ElementTest | AttributeTest | SchemaElementTest | SchemaAttributeTest | PITest | CommentTest | TextTest | AnyKindTest which means, more or less, with all possible variations: [54] KindTest ::= "document-node(...)" | "element(...)" | "attribute(...)" | "schema-element(...)" | "schema-attribute(...)" | "processing-instruction(...)" | "comment()" | "text()" | "node()" So you have a KindTest for each node type (even two for elements and attributes), but for namespace nodes. BTW, you don't support the namespace *axis*, but you support namespace *nodes*, if I'm right. For example xsl:namespace works as expected, and produces a namespace node. > OK. I will look into it. > I assume it also fails with a production build? Yes. Mmh, I maybe spook too early for namespace-uri-for-prefix(). Actually it doesn't seems to be the problem, but xsl:namespace does. If you replace xsl:namespace by xsl:attribute, all runs fine: (drkm)[113] ~/xslt/tests$ cat copy-namespaces.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="my:copy-namespaces.xsl" exclude-result-prefixes="my" version="2.0"> <xsl:output omit-xml-declaration="yes"/> <xsl:template match="root"> <root> <xsl:sequence select="my:copy-namespaces(.)"/> </root> </xsl:template> <!-- Not usefull version that creates attributes of the form prefix="the://namespace/uri". --> <xsl:function name="my:copy-namespaces" as="node()*"> <xsl:param name="context" as="element()"/> <xsl:for-each select="in-scope-prefixes($context)"> <xsl:attribute name="{ . }" select=" namespace-uri-for-prefix(., $context)"/> </xsl:for-each> </xsl:function> </xsl:stylesheet> (drkm)[114] ~/xslt/tests$ cat copy-namespaces.xml <root xmlns:ns="my:namespace"/> (drkm)[115] ~/xslt/tests$ gexslt copy-namespaces.xsl \ copy-namespaces.xml <root ns="my:namespace" xml="http://www.w3.org/XML/1998/namespace"/> (drkm)[116] ~/xslt/tests$ Regards, --drkm ___________________________________________________________________________ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses http://fr.answers.yahoo.com |