[MarkLogic Dev General] embedded html

Danny Sokolsky dsokolsky at marklogic.com
Thu Oct 30 10:19:12 PST 2008

Hi Paul,

You are not being specific about *exactly* what you are doing, so it is hard to tell for sure what is going on.  My guess, though, is that the namespace being used is picked up from your XQuery context.  The following example I think does what you are trying to do:

(: create a document :)
xquery version "1.0-ml";
<html xmlns="http://www.w3.org/1999/xhtml">
<body><p>some stuff here</p></body>
</html>) ;

(: insert a node after the first xhtml p tag :)
xquery version "1.0-ml";
declare namespace xh="http://www.w3.org/1999/xhtml";
declare namespace foo="foo";

<p xmlns="foo">foo</p>) ;

(: look at that document :)
(: returns:
<html xmlns="http://www.w3.org/1999/xhtml">
  <body><p>some stuff here</p><p xmlns="foo">foo</p></body>

Notice that the second p tag is in the "foo" namespace.  Is that what you are trying to do?


From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Paul M
Sent: Thursday, October 30, 2008 8:36 AM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] embedded html


I have the following html:
this is my <sub>html</sub> snippet

I want to add it to my tag:
<mytag xmlns="mine">
this is my <sub>123</sub> snippet

And then add it to my doc using node-insert
However,  sub html element is now in the wrong namespace. So when I perform the following:

<sub xmlns="mine"> is in the wrong namespace

My best solution is creating an additional tag (note ->block<- level tag)
<mytag xmlns="mine">
<div xmlns="htmlns">
this is my <sub>123</sub> snippet

and when I want the html, I simply use

I could also perform a search and replace on every html element before adding the snippet (In perl most likely, so regexp)?
this is my <sub xmlns="htmlns">123</sub> snippet

The only other solution I can see is storing the html not as node by as data (embedded).  This seems somewhat prone to problems though.

How should this be handled. Best practices?

More information about the General mailing list