You can create a use-case specific result document as you go:

for $i in cts:search(doc()//article-title,$term) [1 to 15]
return element journal {
        attribute journal-id { fn:string($i/root()//journal-id) },
      attribute title { $i/root()//title },
        (: copy the author as a child element if it's a structure itself
:)
        $i/root()//author
        (: etc etc... :)
}

In a lot of places we map these documents to java domain objects using
Castor XML.  However, there's drawbacks to that approach since you're
doing a lot of parsing and short-lived object generation.  

I've been trying to push this kind of content processing back into ML
wherever possible.  I still try to be careful about separation of
concern so I write my queries as the result of two functions.  The first
selects relevant content and is reusable, the second wraps it for
formatting.  Java can then just use the result as a stream and put it
where it needs to go.  

The call would look something like this for an html fragment: 
element ul {
  for $j select-journals-by-term($term) 
  return
      element li { 
        attribute id { $j//journal-id },
        $j//title 
      }
    

-Matt
  
-----Original Message-----

Thanks for this.  The alternative model you describe works great if  
I'm returning a single value from Mark Logic.  But what if I want to  
get back multiple values from Mark Logic for each document (e.g.  
author, title, abstract, journal title) so I can display these to the  
user

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to