James,
Thanks.
Helen

>>> "James Clippinger" <[EMAIL PROTECTED]> 08/15/07 3:43 PM >>>
Well, it depends.  I think most people keep attributes in the no
namespace unless there is a convincing reason to use a different
namespace.  On the search side, it would depend on your content format
and your business requirements, but doing global XPath on attributes
(e.g., //@size) tends to be rare, so name collisions of attributes are
generally less of a concern than element-name collisions.

Regards,
James

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Helen Chen
> Sent: Wednesday, August 15, 2007 3:22 PM
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] xhtml loading question
> 
> Thanks for explain it.  
> 
> Is it good habit to make sure all the attributes for the 
> element belong to the same namespace during loading?  Or 
> otherwise maybe attributes without namespace are easier for searching?
> 
> Helen
> 
> >>> "James Clippinger" <[EMAIL PROTECTED]> 
> 08/15/07 3:06 PM 
> >>> >>>
> Helen, default namespaces never apply to unprefixed 
> attributes; attributes without a prefix are always in the no 
> namespace.  This is an XML specification (see
> http://www.w3.org/TR/2006/REC-xml-names-20060816/#defaulting) 
> that has been carried through to XQuery.
> 
> I don't know the reasoning behind that design decision by the 
> recommendation writers and I personally dislike the 
> differential treatment of elements vs. attributes, but it's 
> how the language works.
> 
> Regards,
> James
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf Of Helen 
> > Chen
> > Sent: Wednesday, August 15, 2007 2:35 PM
> > To: General Mark Logic Developer Discussion
> > Cc: Helen Chen
> > Subject: RE: [MarkLogic Dev General] xhtml loading question
> > 
> > Hi James,
> > 
> > I'm interested in this topic and I have an question about the 
> > namespace for the
> > attribute:
> > 
> > At the data loading time, Dev declared namespace as 
> > "http://www.w3.org/1999/xhtml 
> > xdmp:document-insert("/content/htmlchk66.html",
> > <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" 
> > lang="en"> <body> <meta name="org" content="abc-de" /> <meta 
> > name="product" content="electronics" /> <meta name="education" 
> > content="school" /> <meta name="test"
> > content="answer123" /> </body>
> > </html>)
> > 
> > My understanding for namespace is: if you declare the namespace, 
> > unless you change it or it goes out of the scope, all the following 
> > elements and attributes belong to this namespace.
> > 
> > But you mentioned that the attributes in Dev's data does 
> not have any 
> > namespace, I think I misunderstood the concept. Can you explain it 
> > more?
> > 
> > Thanks, Helen
> > 
> > 
> > 
> > >>> "James Clippinger" <[EMAIL PROTECTED]>
> > 08/14/07 5:41 PM
> > >>> >>>
> > Dev, the syntax you used would associate the prefix "html" 
> > with the XHTML namespace; you could use it like this:
> > 
> > declare namespace html="http://www.w3.org/1999/xhtml";
> >  
> > cts:search(xdmp:directory(('/'),"infinity"),
> > cts:and-query((cts:element-attribute-value-query(xs:QName("htm
> > l:meta"),
> > xs:QName("name"),
> > "org"),cts:element-attribute-value-query(xs:QName("html:meta"),
> > xs:QName("content"), "abc-de"))))
> >  
> > Now, you could use the "default element namespace" syntax to set the
> > default:
> >  
> > default element namespace="http://www.w3.org/1999/xhtml";
> >  
> > cts:search(xdmp:directory(('/'),"infinity"),
> > cts:and-query((cts:element-attribute-value-query(xs:QName("meta"),
> > xs:QName("name"),
> > "org"),cts:element-attribute-value-query(xs:QName("meta"),
> > xs:QName("content"), "abc-de"))))
> >  
> > However, this will return no results in your example, because
> > xs:QName() will, when given an unprefixed string, return 
> QNames in the 
> > default element namespace.  This is the right thing for the QNames 
> > being used as elements, but it causes the attribute QNames not to 
> > match since they are in the no namespace.  This version would work:
> >  
> > default element namespace="http://www.w3.org/1999/xhtml";
> > declare namespace no-namespace=""
> >  
> > cts:search(xdmp:directory(('/'),"infinity"),
> > cts:and-query((cts:element-attribute-value-query(xs:QName("meta"),
> > xs:QName("no-namespace:name"),
> > "org"),cts:element-attribute-value-query(xs:QName("meta"),
> > xs:QName("no-namespace:content"), "abc-de"))))
> >  
> > I think the html-prefix form is more intuitive than this 
> one, but it 
> > is legal XQuery and will work just fine.
> >  
> > Regards,
> > James
> > 
> > 
> > 
> > ________________________________
> > 
> >     From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf 
> Of Devadoss 
> > P
> >     Sent: Tuesday, August 14, 2007 5:16 PM
> >     To: General Mark Logic Developer Discussion
> >     Subject: Re: [MarkLogic Dev General] xhtml loading question
> >     
> >     
> >     Thanks James, it's working.
> >      
> >     I couldn't understand, why declaring default namespace 
> is not working 
> > in this case (declare namespace html = 
> > "http://www.w3.org/1999/xhtml";).
> >      
> >     Is it because of xhtml namespace?
> >      
> >     Thanks,
> >     Dev
> >      
> > 
> > 
> >      
> >     On 8/14/07, James Clippinger <[EMAIL PROTECTED] >
> > wrote: 
> > 
> >             Dev, you need to include the XHTML namespace in 
> the element QNames 
> > you create for use in the cts:search() if you want the 
> query to match 
> > those elements.  This would work:
> >              
> >             cts:search(xdmp:directory(('/'),"infinity"),
> > cts:and-query((cts:element-attribute-value-query(fn:QName("
> > http://www.w3.org/1999/xhtml <http://www.w3.org/1999/xhtml> ", 
> > "meta"), xs:QName("name"), 
> > "org"),cts:element-attribute-value-query(fn:QName("
> > http://www.w3.org/1999/xhtml <http://www.w3.org/1999/xhtml> ", 
> > "meta"), xs:QName("content"), "abc-de"))))
> >              
> >             Note that the attribute QNames don't require 
> namespace URIs because, 
> > having not been prefixed in the original source, they are in the no 
> > namespace.  If you wanted to use the fn:QName() function for 
> > consistency, this form also works:
> >              
> >             cts:search(xdmp:directory(('/'),"infinity"),
> > cts:and-query((cts:element-attribute-value-query(fn:QName("
> > http://www.w3.org/1999/xhtml <http://www.w3.org/1999/xhtml> ", 
> > "meta"), fn:QName("", "name"), 
> > "org"),cts:element-attribute-value-query(fn:QName("
> > http://www.w3.org/1999/xhtml <http://www.w3.org/1999/xhtml> ", 
> > "meta"), fn:QName("", "content"), "abc-de"))))
> >              
> >             Regards,
> >             James
> > 
> > 
> > ________________________________
> > 
> >                     From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf 
> Of Devadoss 
> > P
> >                     Sent: Tuesday, August 14, 2007 4:49 PM
> >                     
> >                     To: General Mark Logic Developer Discussion
> >                     Subject: Re: [MarkLogic Dev General] 
> xhtml loading question
> >                     
> > 
> >                      
> >                     
> >                     James,
> >                      
> >                     This is the query used to load the document,
> >                     xdmp:document-insert("/content/htmlchk66.html",
> >                     <html xmlns="http://www.w3.org/1999/xhtml "
> > xml:lang="en" lang="en">
> >                     <body> 
> >                     <meta name="org" content="abc-de" />
> >                     <meta name="product" content="electronics" />
> >                     <meta name="education" content="school" /> 
> >                     <meta name="test" content="answer123" /> 
> >                     </body>
> >                     </html>)
> >                      
> >                     and my cts query is 
> >                     cts:search(xdmp:directory(('/'),"infinity"),
> > cts:and-query((cts:element-attribute-value-query(xs:QName("meta"),
> > xs:QName("name"),
> > "org"),cts:element-attribute-value-query(xs:QName("meta"),
> > xs:QName("content"), "abc-de")))) 
> >                      
> >                     This query returns result, if I load 
> > document without xmlns.
> >                      
> >                     Thanks,
> >                     Dev
> >                     
> >                      
> >                     On 8/14/07, James Clippinger
> > <[EMAIL PROTECTED] > wrote: 
> > 
> >                             Dev, can you send the 
> > cts:search() call you're using for your search?
> >                              
> >                             Thanks,
> >                             James
> > 
> > 
> > ________________________________
> > 
> >                             From:
> > [EMAIL PROTECTED] [mailto:
> > [EMAIL PROTECTED] On Behalf Of Devadoss P
> >                             Sent: Tuesday, August 14, 2007 4:33 PM 
> >                             To: General Mark Logic Developer
> > Discussion
> >                             Subject: Re: [MarkLogic Dev 
> > General] xhtml loading question
> >                             
> >                              
> >                             
> >                             James and Mike,
> >                              
> >                             How to resolve
> > (xmlns="http://www.w3.org/1999/xhtml";) namespace conflict in 
> > xquery; I loaded html document (which has xmlns namespce 
> > defined) to MarkLogic and tried to query its element by using 
> > cts:search(), but it returns empty row. 
> >                              
> >                             Can you help me to resolve 
> > namespace issue?
> >                              
> >                             Thanks,
> >                             Dev
> >                             
> >                              
> >                             On 8/14/07, Alex Rice
> > <[EMAIL PROTECTED]> wrote: 
> > 
> >                             James and Michael:
> >                             
> >                             i had not even thought of namespaces.
> > now I am getting nodes back and
> >                             can use the declare namespace 
> > feature etc. Thank you both for 
> >                             responding.
> >                             
> >                             Alex Rice
> >                             
> >                             
> >                             On 8/14/07, James Clippinger
> > <[EMAIL PROTECTED] > wrote:
> >                             > Alex, I'm not familiar with 
> > the XHTML created by Dreamweaver or UpCast, 
> >                             > but I suspect the XHTML 
> > elements both tools create are in the XHTML
> >                             > namespace.  Try this (keeping 
> > in mind the wildcard-namespace syntax may 
> >                             > be slow):
> >                             >
> >                             >
> > doc("/SFI/Update/news/articletest2/test.xml")//*:p 
> >                             >
> >                             > If it returns items, you can 
> > see which namespace each item is in and go
> >                             > from there.
> >                             >
> >                             > Regards, 
> >                             > James
> >                             >
> >     
> > _______________________________________________
> >                             General mailing list 
> >                             [email protected] 
> >     
> > http://xqzone.com/mailman/listinfo/general 
> >                             
> > 
> > 
> > 
> >     
> > _______________________________________________
> >                             General mailing list
> >                             [email protected] 
> >     
> > http://xqzone.com/mailman/listinfo/general 
> >                             
> >                             
> > 
> > 
> > 
> >             _______________________________________________
> >             General mailing list
> >             [email protected] 
> >             http://xqzone.com/mailman/listinfo/general 
> >             
> >             
> > 
> > 
> > _______________________________________________
> > General mailing list
> > [email protected] 
> > http://xqzone.com/mailman/listinfo/general 
> > 
> _______________________________________________
> General mailing list
> [email protected] 
> http://xqzone.com/mailman/listinfo/general 
> _______________________________________________
> General mailing list
> [email protected] 
> http://xqzone.com/mailman/listinfo/general 
> 
_______________________________________________
General mailing list
[email protected] 
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to