Hate replying to my own posting but I think the problem can be solved
using the second suggestion of my previous posting. Here it is again.
It looks as if the <div id="header"> element of your page.html is no
longer part of the output. I'm woundering if at compile time empty
nodes are being eleminated from the XMLObject. You might also try the
following. Make sure the div id from design.html is different from the
id of the div in page.html.
design.html
<body>
<div id="dynheader">header content</div>
</body>
Page.html
<body>
<div id="header">HEADER GOES HERE</div>
</body>
Actually leave the text "HEADER GOES HERE" in the div. Then after
appending the dynheader element remove the first node. Just a thought.
Node headerNode =
returnHtml.importNode(headerFooter.getElementHeader(),true);
node.appendChild(headerNode);
node.removeChild(node.getFirstChild());
James
James Rochford wrote:
Hmmmm...
Unless I'm mistaken the following line should if working correctly
return only import the header element. Not sure why the whole
document would be imported. Maybe it has something to do with the fact
the the node being imported has the same id as the node it is getting
inserted into. Not sure. Anyone else see the problem here? Maybe try
changing the id value in your design.html to something like.
headerFooter.html
<body>
<div id="dynheader">Header content</div>
</body>
Node headerNode =
returnHtml.importNode(headerFooter.getElementHeader(),true);
node.appendChild(headerNode);
returnHtml.html
<body>
<div id="header">
<div id="dynheader">Header Content</div>
</div>
</body>
It looks as if the <div id="header"> element of your page.html is no
longer part of the output. I'm woundering if at compile time empty
nodes are being eleminated from the XMLObject. You might also try the
following.
design.html
<body>
<div id="dynheader">header content</div>
<body>
Page.html
<body>
<div id="header">HEADER GOES HERE</div>
</body>
Actually leave the text "HEADER GOES HERE" in the div. Then after
appending the dynheader element remove the first node. Just a thought.
Node headerNode =
returnHtml.importNode(headerFooter.getElementHeader(),true);
node.appendChild(headerNode);
node.removeChild(node.getFirstChild());
Erik Rasmussen wrote:
--- James Rochford <jrochford@xxxxxxxxx> 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
------------------------------------------------------------------------
--
You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx
mailing list.
To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
------------------------------------------------------------------------
--
You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx mailing list.
To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
------------------------
James Rochford
Software Developer
Samba Holdings, Inc.
(505) 797-2622 ext. 129
--
You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx mailing list.
To unsubscribe:
mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
For general help:
mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/wws
|