Hi David
For the XSLT function id() to work, the XSLT processor needs to have a DTD
available, because it needs to know which attributes are of type ID. The
XSLT processor can then automatically index every element with this
attribute. Many markup languages have an ID attribute called "id", but not
all attributes called "id" are of type ID. So in XSLT, if your doc has no
doc-type, then the id() will not work. It seems that this DTD information is
not being passed through the pipeline to the transformer. This makes a kind
of sense, though, since in a pipeline the doc-type may well change from one
stage of the pipeline to the next.
There is a simple solution though: use the key() function. The key()
function is very similar to the id() function - but more powerful. You can
emulate id() with key() very easily, and it will work whether a DTD is
available or not.
For example, to declare a key which indexes every element with an "id"
attribute, using the value of that attribute as a key, add the following
element to your <xsl:stylesheet>
<xsl:key name="id" match="[EMAIL PROTECTED]" use="@id"/>
Then, wherever you would have used the expression "id($foo)", replace it
with: "key('id',$foo)".
Cheers!
Con
> -----Original Message-----
> From: David Leangen [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 31 January 2004 21:39
> To: [EMAIL PROTECTED]
> Subject: Need to include DOCTYPE definition after transform
>
>
>
> Hello!
>
> I am using multiple <map:transform>s in my pipeline. I would
> like for the
> transforms to output the DOCTYPE declaration. I am using v2.1.3.
>
> Generally, my sitemap is something like:
>
> <map:match pattern="*.html">
> <map:generate src="{1}.xml"/>
> <map:transform src="t1.xsl"/>
> <map:transform src="t2.xsl"/>
> <map:serialize type="html"/>
> </map:match>
>
> After the transform "t1", the intermediate file loses its DOCTYPE.
> Therefore, "t2" will not work properly for me.
>
> I read in some mailing list that Cocoon (v??) doesn't support
> <xsl:output>,
> but that this can be done with <?cocoon-process type="xxx"?>.
> However, I
> couldn't find any clear documentation on how to implement this.
>
> Can anybody help me with this?
>
> If you want to know why I need this, keep reading. Otherwise,
> thanks for
> stopping by!
>
>
>
> Reason:
>
> I have been having a problem with the id() function in
> Cocoon, and I've
> narrowed down the problem.
>
> It seems that this only occurs when using more than one
> <map:transform> in
> the pipeline. If I only use one transform, then the id()
> function always
> returns an empty string (or NULL, or whatever).
>
> I've also notice that if I do not include a DOCTYPE
> declaration, even for a
> since transform, the same behaviour occurs. So, it seems that
> the DOCTYPE
> definition is absolutely necessary for the id() function to
> work properly.
> At least this is so in my case, since I am using namespaces.
>
> Therefore, when I use multiple transforms, after the first
> transform, the
> DOCTYPE definition gets "erased". Since the DOCTYPE is no
> longer there, the
> id() function will no longer work in my second transform. So,
> that's why I
> need to include it.
>
>
> Thanks a lot!!
>
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]