Re: [xmlc] Headers and footers

Erik Rasmussen <[email protected]> Thu, 1 Sep 2005 09:22:29 -0700 (PDT)
Newsgroups gmane.comp.java.enhydra.xmlc
Message-ID <[email protected]>
This is a multi-part message in MIME format...

------------=_1125591790-4880-161
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


--- James Rochford <[email protected]> wrote:
> class RenderView{
>     // object that contains getters for the request
> and response.
>     private HttpComs httpCom;
> ...
>     public XMLCFactory getFactory(){
>         XMLCFactory factory = 
>
XMLCContext.getContext(httpCom.getServlet()).getXMLCFactory();
>         return factory;
>     }
> 
> public void drawheader(XMLObject returnHtml){
>         // Get the page containing the header and
> footer.
>         headerFooterHTML headerFooter 
>
=(headerFooterHTML)this.getFactory().create(headerFooterHTML.class);
> 
> ...
> Update the header content
> ...
> 
>         // Get the node in the return html where I
> want to insert the 
> header. Import the header node
>        // from the headerFooter.  Append the node to
> the <div 
> id="header"> element.
>         Node node =
> returnHtml.getElementById("header");
>         if(node != null){
>             Node headerNode = 
>
returnHtml.importNode(headerFooter.getElementHeader(),true);
>             node.appendChild(headerNode);
>         }
>      
>             XMLCContext xmlc =
> XMLCContext.getContext(httpCom.getServlet());
>             OutputOptions outo = 
> xmlc.createOutputOptions(httpCom.getRequest(), 
> httpCom.getResponse(),returnHtml);
>             outo.setPrettyPrinting(true);
>             xmlc.writeDOM(httpCom.getRequest(),
> httpCom.getResponse(), 
> outo ,returnHtml);
>  }
> }

When I do this, it's inserting the entire document
starting from the specified div to the destination
document.  That's confusing.  Let me show an
example...

My design.html: (the equiv of your headerFooter.html)
----
<html>
<head>
	<title>Design template</title>
</head>
<body>
<div id="header">
	This is the header for <span id="siteName_1">Widgets
R Us</span>.
</div>
<div id="footer">
	This is the footer for <span id="siteName_2">Widgets
R Us</span>.
</div>
end of doc
</body>
</html>
----

My page.html:
----
<html>
<head>
	<title>My page</title>
</head>
<body>
<div id="header"></div>
<div id="content>
  Page content here
</div>
<div id="footer"></div>
</body>
</html>
----

When I appendChild() the header node from design.html
to the header node of my page.html, what gets inserted
is:
----
<div id="header">
	This is the header for <span id="siteName_1">Widgets
R Us</span>.
</div>
<div id="footer">
	This is the footer for <span id="siteName_2">Widgets
R Us</span>.
</div>
end of doc
----

Obviously, what I want it to insert would just be:
----
<div id="header">
	This is the header for <span id="siteName_1">Widgets
R Us</span>.
</div>
----
...or even more ideal would be just the contents of
the header div, but I can live with the div tags in
there too.

It doesn't just append the contents of the header div,
it appends EVERYTHING after it.  Ditto for footer. 
When I appendChild() the footer info, what gets
inserted is:
----
<div id="footer">
	This is the footer for <span id="siteName_2">Widgets
R Us</span>.
</div>
end of doc
----

I'm calling importNode() just like you are.  I could
get around this by having separate header.html and
footer.html files, but gross!  I must be doing
something wrong.  Apparently the "node" that you get
back is really a pointer to the rest of the tree,
including nodes at lower depths.  How
counter-intuitive!

Any ideas?

Thanks,
Erik


		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 


------------=_1125591790-4880-161
Content-Type: text/plain; name="message-footer.txt"
Content-Disposition: inline; filename="message-footer.txt"
Content-Transfer-Encoding: 8bit


--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

------------=_1125591790-4880-161--