Ah. Ok. Thank you.

I figured it was for good reason.

> To: general@developer.marklogic.com
> Date: Wed, 24 Aug 2011 15:47:53 -0700
> From: mary.holst...@marklogic.com
> Subject: Re: [MarkLogic Dev General] Sequences for attribute values
> 
> On Wed, 24 Aug 2011 15:33:16 -0700, seme...@hotmail.com  
> <seme...@hotmail.com> wrote:
> 
> > If I'm reading this right, the XQuery 1.0 spec allows zero or one values  
> > for an attribute: http://www.w3.org/TR/xquery/#id-computedAttributes
> >
> > [113]            
> > CompAttrConstructor<http://www.w3.org/TR/xquery/#prod-xquery-CompAttrConstructor>
> >            
> > ::=          "attribute"  
> > (QName<http://www.w3.org/TR/xquery/#prod-xquery-QName> | ("{"  
> > Expr<http://www.w3.org/TR/xquery/#doc-xquery-Expr> "}")) "{"  
> > Expr<http://www.w3.org/TR/xquery/#doc-xquery-Expr>? "}"
> >
> >
> > But MarkLogic will allow me to use a computed constructor to make an  
> > attribute that has a sequence for its value, but it doesn't look like  
> > the sequence stays a sequence:
> >
> > let $xml := <root>{attribute { "greeting" } { ("hi", "bye") }}</root>
> > return ($xml/@greeting/fn:data(.))[1]
> >
> > => hi bye
> >
> >
> > Except for class attributes in the xhtml namespace, which apparently can  
> > have a sequence for their value:
> >
> > declare namespace xhtml = "http://www.w3.org/1999/xhtml";;
> > let $xml := <xhtml:div>{attribute { "class" } { ("red", "green")  
> > }}</xhtml:div>
> > return ($xml/@class/fn:data(.))[1]
> >
> > => red
> 
> What is going on is that the attribute always has a single value.
> The constructor atomizes the sequence of strings to create a string
> which is the space-separated concatenation of input sequence.
> However, there is a schema in scope for the XHTML namespace, and that
> schema says that the class attribute is a list simple type.
> 
> If you did an fn:string(.) instead of fn:data(.) you'd get the same
> thing in both cases -- a single string with a space in it.
> 
> The XQuery spec is not entirely clear about how list simple types should
> be handled, so we did what we felt was the logical thing when getting
> the typed value out (fn:data): we turn it into a sequence of simple
> values.  This has the benefit, as you observe, of letting you
> do things like //xhtml:p[@class="foo"] and having it match when there
> is more than one item in that list.
> 
> This applies to all attributes (or elements, for that matter) declared
> as a simple list type.
> 
> //Mary
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
                                          
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to