You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Michael Los <me...@mitre.org> on 2004/03/29 16:37:40 UTC

Is transform done by XSL Portlet namespace aware?

Is the transform done by XSLPortlet namespace aware?

Judging by the example xsl documents in the jetspeed distribution, I 
would think yes,
but the behavior with my own documents is not as I expect.

I started with the XML document listed below under Example 1.  I 
specified the namespaces
for rdf and dublin core (dc).  Elements are qualified appropriately.  In 
the xsl
stylesheet, I defined the namespaces for rdf and dublin core.  For 
convenience I used
the same prefixes, rdf and dc.  When I apply the xml document to the 
stylesheet via the
XSL portlet, the output is the content of each element, one per line.  i.e.,
    Document Title Here
    29 March 2004
    John Doe
    Subject
    Some Description Text
    Copyright (c) 2003 - 2004 The MITRE Corporation.  All rights reserved.
    application/vnd.ms-powerpoint
    en

If I delete the namespace prefixes from both the xml and xsl documents, 
the output is
what I expect.  See Example 2.  I set the rdf namespace to be the 
default in both the
xml and xsl.  For the test I deleted the dc prefix on title and date.  
In this case,
Jetspeed outputs the html.  In this example, dc:rights is not recognized 
during the transform.

This makes me wonder 1) what I'm doing wrong, 2) if XSL portlet 
processing supports
namespaces.  FWIW, I noteced in the XALAN faq 
(http://xml.apache.org/xalan-j/faq.html#faq-N10201)
and the unofficial JAXP faq at 
http://xml.apache.org/~edwingo/jaxp-faq.html#nsDefaults
that there is a warning that JAXP is not namespace aware by default.  
The code snippet xalan faq to instantiate a SAXParserFactory looks very 
similar
to what is going on in jetspeed.util.SimpleTransform.

Any comments are appreciated,

-- Michael Los





----------------------------------------
Example 1:
Jetspeed outputs content of each element; one per line.
Applying to xalan on command line results in html output and "IN 
DESCRIPTION" being printed
-----------------------------------------
=================
XML Doc
=================
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:dc="http://purl.org/dc/elements/1.1/">  
  <rdf:Description about="http://somwhere.org/fileref.ppt">
    <dc:title>Document Title Here</dc:title>
    <dc:date>29 March 2004</dc:date>
    <dc:creator>John Doe</dc:creator>
    <dc:subject>Subject</dc:subject>
    <dc:description>Some Description Text</dc:description>
    <dc:rights>Copyright (c) 2003 - 2004 The MITRE Corporation.  All 
rights reserved.</dc:rights>
    <dc:format>application/vnd.ms-powerpoint</dc:format>
    <dc:language>en</dc:language>
  </rdf:Description>
</rdf:RDF>

=================
XSL Doc
=================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:dc="http://purl.org/dc/elements/1.1/">  
<xsl:output indent="yes" method="html"/>                

<xsl:template match="/rdf:RDF">
<html><head></head><body>
<xsl:apply-templates select="rdf:Description" />
</body></html>
</xsl:template>

<xsl:template match="rdf:Description">
IN DESCRIPTION
  <div><a>
    <xsl:attribute name="href"><xsl:value-of 
select="@about"/></xsl:attribute>
    <xsl:value-of select="dc:title"/>
  </a></div>
  <xsl:value-of select="dc:date"/><br />
  <xsl:value-of select="dc:rights"/>
</xsl:template>
 
</xsl:stylesheet>

------------- END EXAMPLE 1 -------------------

----------------------------------------
Example 2:
Jetspeed outputs HTML. "IN DESCRIPTION" is printed.  Rights element is 
not recognized
Running xalan directly on command line results in every content element 
printed out.
-----------------------------------------
=================
XML Doc
=================
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:dc="http://purl.org/dc/elements/1.1/">  
  <Description about="http://somwhere.org/fileref.ppt">
    <title>Document Title Here</title>
    <date>29 March 2004</date>
    <dc:creator>John Doe</dc:creator>
    <dc:subject>Subject</dc:subject>
    <dc:description>Some Description Text</dc:description>
    <dc:rights>Copyright (c) 2003 - 2004 The MITRE Corporation.  All 
rights reserved.</dc:rights>
    <dc:format>application/vnd.ms-powerpoint</dc:format>
    <dc:language>en</dc:language>
  </Description>
</RDF>


=================
XSL Doc
=================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:dc="http://purl.org/dc/elements/1.1/">  
<xsl:output indent="yes" method="html"/>                

<xsl:template match="/RDF">
  <html><head></head><body>
  <xsl:apply-templates select="Description" />
  </body></html>
</xsl:template>

<xsl:template match="Description">
IN DESCRIPTION
  <div><a>
    <xsl:attribute name="href"><xsl:value-of 
select="@about"/></xsl:attribute>
    <xsl:value-of select="title"/>
  </a></div>
  <xsl:value-of select="date"/><br />
  <!-- rights is not matched in jetspeed; not namespace aware? -->
  <xsl:value-of select="dc:rights"/>
</xsl:template>
</xsl:stylesheet>

------------- END EXAMPLE 2 -------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org