cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Weinger" <gwein...@itmedicine.net>
Subject DOMStreamer and namespaces
Date Thu, 26 Jul 2001 00:00:19 GMT
I have a question regarding  DOMStreamer behavior and namespaces.  My
problem appeared when I upgraded to C2b2 from C2b1.  

I have an XSP that drops a org.w3c.dom.Node generated by some legacy
code into an <xsp:expr> tag.  

If I only generate and serialize this Node I can see the results.  When
I try to transform these results in a stylesheet, the stylesheet can't
match them.  This worked fine in C2b1.  From testing I know this has
something to do with new behavior regarding namespaces.  

Can somebody please suggest a fix?
(BTW the examples below are all very brief.)

The xsp page looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
          language="java"
          xmlns:xsp="http://apache.org/xsp"
>
<page>
<xsp:logic>
   // . . .
   org.w3c.dom.Node anode = legacyCode.getNode();
</xsp:logic>
<xsp:expr>anode</xsp:expr>
</page>
</xsp:page>


The raw XSP output looks like this:

<page xmlns:xsp="http://apache.org/xsp">
<question_form currentID="37" id="2" sectionID="2"
xmlns:p3n="http://www.p3n.org/p3n">
      <question id="37" text="How often do you travel outside the United
States?" type="single-select" vieworder="1">
           	<answer id="7" text="1-2 weeks" vieworder="1"></answer>
           	<answer id="8" text="3-5 weeks" vieworder="1"></answer>
      </question>
	<question id="38" text="Do you play chess" type="single-select"
vieworder="2">
      	<answer id="3" text="Yes" vieworder="1"></answer>
            <answer id="4" text="No" vieworder="1"></answer>
      </question>
</question_form>
</page>	


The XSL just tries to do this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:p3n="http://www.p3n.org/p3n"
        xmlns:xsp="http://apache.org/xsp"
>
  <xsl:template name="catchall"
match="@*|*|text()|processing-instruction()" priority="-1">
	<xsl:copy>
		<xsl:apply-templates
select="@*|*|text()|processing-instruction()"/>
	</xsl:copy>
  </xsl:template>


</xsl:stylesheet>

And all that comes out is:

<page xmlns:xsp="http://apache.org/xsp">
</page>


If I write the "raw" result listed above directly from an XSP, the
namespaces resolve correctly, and the XSL works as expected.  My guess
is that the DOMStreamer isn't correctly identifying the namespace for
each node.  This may have something to do the way that the DOM is built;
I will investigate that.  I also know that implementing my own
DocumentFragment would help.  

However, I was wondering if anyone could tell me what has changed,
whether it's in the DOMStreamer, or whether stylesheets are handling
namespaces more strictly now.  What's going on?

Thanks,
Greg 
----------------
Gregory Weinger
Senior Analyst
UCLA Telemedicine



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message