This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Mozilla XML > September 2005 > XSL content:encoded troubles





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author XSL content:encoded troubles
Michael Vincent van Rantwijk

2005-08-31, 7:43 pm

Hi,

First of all, there's no XSL newsgroup so I'll have to post my question
in the *mozilla.style and mozilla.xml newsgroup, because I don't know
which one to use (and maybe these are both wrong).

My question is: should something like this work in Mozilla?

<xsl:attribute name="description">
<xsl:choose>
<xsl:when test="content:encoded">
<xsl:value-of select="content:encoded"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="description"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>

To read/assign the data of:

<content:encoded>
<content:encoded>

to the description attibute?

Please note that I am still learning so I might have made one or more
errors, because I don't fully understand XSL yet, so it would be nice if
anyone could help me with this problem.

Thank,
Michael
Martin Honnen

2005-09-01, 7:42 pm



Michael Vincent van Rantwijk wrote:


> First of all, there's no XSL newsgroup so I'll have to post my question
> in the *mozilla.style and mozilla.xml newsgroup, because I don't know
> which one to use (and maybe these are both wrong).


For Mozilla specific XSLT questions there is the newsgroup
netscape.public.mozilla.layout.xslt. But the topic there is not general
XSLT questions.


> My question is: should something like this work in Mozilla?
>
> <xsl:attribute name="description">
> <xsl:choose>
> <xsl:when test="content:encoded">
> <xsl:value-of select="content:encoded"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="description"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:attribute>
>
> To read/assign the data of:
>
> <content:encoded>
> <content:encoded>


Is that supposed to be a snippet of XML? Then it should probably look
<content:encoded>
</content:encoded>

As for the XSLT it looks fine as a snippet but of course to write an
XPath expression like e.g. content:encoded you need to make sure that
the prefix content is bound to a namespace URI. So make sure your
stylesheet element for instance has e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:content="http://example.com/2005/09/01/n1">
where you replace http://example.com/2005/09/01/n1 with the namespace
URI the elements in the source document are in.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Lucky

2005-09-01, 7:42 pm

Michael Vincent van Rantwijk wrote:
> Hi,
>
> First of all, there's no XSL newsgroup so I'll have to post my question
> in the *mozilla.style and mozilla.xml newsgroup, because I don't know
> which one to use (and maybe these are both wrong).
>
> My question is: should something like this work in Mozilla?
>
> <xsl:attribute name="description">
> <xsl:choose>
> <xsl:when test="content:encoded">
> <xsl:value-of select="content:encoded"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="description"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:attribute>
>
> To read/assign the data of:
>
> <content:encoded>
> <content:encoded>
>
> to the description attibute?
>
> Please note that I am still learning so I might have made one or more
> errors, because I don't fully understand XSL yet, so it would be nice if
> anyone could help me with this problem.
>
> Thank,
> Michael

replied to your post in n.p.m.l.xslt
Michael Vincent van Rantwijk

2005-09-01, 7:42 pm

Martin Honnen wrote:
>
>
> Michael Vincent van Rantwijk wrote:
>
>
>
> For Mozilla specific XSLT questions there is the newsgroup
> netscape.public.mozilla.layout.xslt. But the topic there is not general
> XSLT questions.


So I noticed, thanks anyway.

>
> Is that supposed to be a snippet of XML? Then it should probably look
> <content:encoded>
> </content:encoded>


Yeah, just a hasty post and a stupid little typo.

> As for the XSLT it looks fine as a snippet but of course to write an
> XPath expression like e.g. content:encoded you need to make sure that
> the prefix content is bound to a namespace URI.


Yikes, I don't have that, that must be it!

> So make sure your
> stylesheet element for instance has e.g.
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
> xmlns:content="http://example.com/2005/09/01/n1">
> where you replace http://example.com/2005/09/01/n1 with the namespace
> URI the elements in the source document are in.


Do I need to add the output of
document.documentElement.namespaceURI as URI for xmlns:content="" ?

Please note that I don't know if that works, just a wild guess ;)

Thanks for helping me out,
Michael
Martin Honnen

2005-09-02, 7:29 pm



Michael Vincent van Rantwijk wrote:


>
>
> Do I need to add the output of
> document.documentElement.namespaceURI as URI for xmlns:content="" ?


No, not necessarily, it all depends on your input document and the
namespaces used there. You were using an XPath expression
content:encoded
so you are looking for elements in your input document probably where
the local name of the element is 'encoded' and the element is in some
namespace. Which namespace that is I don't know and can't tell without
seeing the input document. It can be simple that you just have elements
all in one default namespace e.g.
<root xmlns="http://example.com/2005/09/02/ns1">
<encoded />
</root>
you can have all elements being in the same namespace but using a prefix
in the names e.g.
<content:root xmlns:content="http://example.com/2005/09/02/ns1">
<content:encoded />
</content:root>
But you could have some elements in no namespace and nevertheless an
encoded element in some namespace e.g.
<root>
<content:encoded xmlns:content="http://example.com/2005/09/02/ns1" />
</root>

So the namespaceURI is certainly somewhere in the input document but no
necessarily the one of the documentElement.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Michael Vincent van Rantwijk

2005-09-03, 7:18 pm

Martin Honnen wrote:
>
>
> Michael Vincent van Rantwijk wrote:
>
>
>
> No, not necessarily, it all depends on your input document and the
> namespaces used there. You were using an XPath expression
> content:encoded
> so you are looking for elements in your input document probably where
> the local name of the element is 'encoded' and the element is in some
> namespace. Which namespace that is I don't know and can't tell without
> seeing the input document. It can be simple that you just have elements
> all in one default namespace e.g.
> <root xmlns="http://example.com/2005/09/02/ns1">
> <encoded />
> </root>
> you can have all elements being in the same namespace but using a prefix
> in the names e.g.
> <content:root xmlns:content="http://example.com/2005/09/02/ns1">
> <content:encoded />
> </content:root>
> But you could have some elements in no namespace and nevertheless an
> encoded element in some namespace e.g.
> <root>
> <content:encoded xmlns:content="http://example.com/2005/09/02/ns1" />
> </root>
>
> So the namespaceURI is certainly somewhere in the input document but no
> necessarily the one of the documentElement.


Hm, it doesn't seem like the best thing to do, but it might be valid, so
I understand it.

Michael
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews