Thanks again to everyone for their suggestions.  Very enlightening.

David

On Oct 18, 2012, at 10:54 PM, Erik Hennum <erik.hen...@marklogic.com> wrote:

> Hi, David:
> 
> As Damon points out, two-tier XQuery web apps are extraordinarily productive.
> 
> If you want to do a 3-tier web app with JVM in the middle tier, you have lots 
> of choices even
> in pure Java for going from the JSON or XML model to the webapp controller.
> 
> To summarize some of the most typical:
> 
> *  If you don't have any pre-existing XML, you can use JAXB to roundtrip POJO 
> tree structures to
>    and from XML. JAXB is simple when the data structure design is sourced in 
> Java instead of XML.
> 
> *  If you have pre-existing XML, you can use a tree API such as JDOM or XOM 
> or a streaming
>   API such as XStream.
> 
> *  If you have pre-existing JSON, you can use GSON or Jackson as a tree or 
> streaming API.
> 
> As you note, some JVM languages like Groovy and Scala have special facilities 
> for structured
> markup.  If those don't meet your requirements, the JVM language can still 
> use the Java libraries
> above. 
> 
> 
> Erik Hennum
> 
> ________________________________________
> From: general-boun...@developer.marklogic.com 
> [general-boun...@developer.marklogic.com] On Behalf Of Damon Feldman 
> [damon.feld...@marklogic.com]
> Sent: Thursday, October 18, 2012 7:08 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Scala and XCC
> 
> David,
> 
> I think that's where you're going to develop new ideas. I would do it in a 
> view layer inside MarkLogic - renderEmployees.xqy or something like this:
> 
> let $employees :=
> <employees>
>    <employee>
>        <name id="1234">
>            <first>Bob</first>
>            <last>Smith</last>
>            <address>
>                <street>1234 Oak St.</street>
>                <city>San Diego</city>
>                <state>CA</state>
>            </address>
>        </name>
>    </employee>
>    <employee>
>        <name id="2345">
>            <first>Sally</first>
>            <last>Smith</last>
>            <address>
>                <street>1234 Elm St.</street>
>                <city>Los Angeles</city>
>                <state>CA</state>
>            </address>
>        </name>
>    </employee>
> </employees>
> for $e in $employees/employee
> return xdmp:document-insert(concat("/employee/", 
> $e/name/@id/string<mailto:$e/name/@id/string>()), $e)
> ; (: transaction end. start new tx :)
> <html>
> <body>
>  <table border="1">
>  {
>  for $e in /employee
>  return
>    <tr><td>{concat($e/name/first, " ", 
> $e/name/last)}</td><td>{$e//state/text()}</td></tr>
>  }
>  </table>
> </body>
> </html>
> 
> Or you could send XML right to a smart table widget in the browser, or send 
> JSON via the json libraries. But you may find a better way to use Scala too.
> 
> Yours,
> Damon
> 
> ________________________________
> From: general-boun...@developer.marklogic.com 
> [general-boun...@developer.marklogic.com] On Behalf Of David Sargeant 
> [da...@dsargeant.com]
> Sent: Thursday, October 18, 2012 9:40 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Scala and XCC
> 
> How would you normally process a nested xml structure after retrieving it?  
> Or would you transform in MarkLogic first?  For example, let's say I had the 
> following stored in the db and wanted to display it on a web page.  I'm using 
> an MVC architecture, so the HTML for my view is already defined, and I just 
> want to iterate over the nested structure.
> 
> <employees>
>    <empolyee>
>        <name id="1234">
>            <first>Bob</first>
>            <last>Smith</last>
>            <address>
>                <street>1234 Oak St.</street>
>                <city>San Diego</city>
>                <state>CA</state>
>            </address>
>        </name>
>    </employee>
>    <empolyee>
>        <name id="2345">
>            <first>Sally</first>
>            <last>Smith</last>
>            <address>
>                <street>1234 Elm St.</street>
>                <city>Los Angeles</city>
>                <state>CA</state>
>            </address>
>        </name>
>    </employee>
> </employees>
> 
> On Oct 18, 2012, at 7:40 PM, Damon Feldman 
> <damon.feld...@marklogic.com<mailto:damon.feld...@marklogic.com>> wrote:
> 
> David,
> 
> 
> 
> I like how you are thinking - why not have good XML support all the way 
> through the stack? You should be able to do more in Scala than in Java, since 
> Java's XML handling is so painful.
> 
> 
> 
> I think your division of work between XQuery/XSLT in the MarkLogic Server and 
> Scala processing may depend on speed and data volumes. If the operation is 
> going to turn a lot of data into a little data, or do heavy processing, do it 
> in MarkLogic.
> 
> E.g. if you want the SSNs of all the People named Bob you could have Scala 
> invoke
> 
> /Person
> 
> in MarkLogic and filter out everyone other than Bob, then throw away all data 
> but the SSN. Or you could invoke
> 
> /Person[name="Bob"]
> 
> in MarkLogic and use Scala to pull the SSN from the resulting full XML 
> doc(s). More interesting is only moving the SSN to minimize serialization, 
> parsing, GC and network traffic. Do this in MarkLogic:
> 
> /Person[name="Bob"]//ssn.text()
> 
> and just use the resulting string in Scala. If you do return XML, I suspect 
> Scala's XML parsing (scala.xml.pull.Source ?) will parse it to the Scala mode 
> most efficiently.
> 
> Damon
> 
> 
> 
> --
> Damon Feldman,
> Sr. Principal Consultant, MarkLogic
> 
> ________________________________________
> From: 
> general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
>  
> [general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>]
>  On Behalf Of David Lee 
> [david....@marklogic.com<mailto:david....@marklogic.com>]
> Sent: Thursday, October 18, 2012 4:09 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Scala and XCC
> 
> First off, are there other things you are doing that need Scala ?
> I think you will find the XQuery support native to MarkLogic to be vastly 
> better then the XML support in Scala,
> easier to use and more efficient.
> 
> But supposing you do need or want scala.  Our latest MarkLogic 6.0 has a new 
> Java API
> I belive Scala runs in the Java JVM and can call Java directly ?
> If so this may be what you are looking for
> http://developer.marklogic.com/products/java
> 
> Also you can call MarkLogic using a REST (plain old HTTP) request and get 
> back XML which you can then (hopefully) get Scala to parse and turn into a 
> Scala XML element.
> 
> 
> 
> -----------------------------------------------------------------------------
> David Lee
> Lead Engineer
> MarkLogic Corporation
> d...@marklogic.com<mailto:d...@marklogic.com>
> Phone: +1 812-482-5224
> Cell:  +1 812-630-7622
> www.marklogic.com<http://www.marklogic.com>
> 
> 
> 
> -----Original Message-----
> From: 
> general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
>  
> [mailto:general-boun...@developer.marklogic.com<mailto:boun...@developer.marklogic.com>]
>  On Behalf Of David Sargeant
> Sent: Thursday, October 18, 2012 4:04 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Scala and XCC
> 
> In Scala I can do the following (examples from a REPL session):
> 
> scala> val david = 
> <person><name>David</name><occupation>developer</occupation></person>
> david: scala.xml.Elem = 
> <person><name>David</name><occupation>developer</occupation></person>
> 
> scala> (david \ "name").text
> res3: String = David
> 
> I'm wondering how to query MarkLogic using XCC and transform the results into 
> a scala.xml.Elem object so I can easily query the xml or map over it.  See 
> the following slides for some more things you can do with xml in Scala - 
> http://www.dzone.com/links/r/xml_processing_in_scala.html.
> 
> 
> David
> 
> On Oct 18, 2012, at 3:28 PM, David Lee 
> <david....@marklogic.com<mailto:david....@marklogic.com>> wrote:
> 
>> To help answer you, could you provide details ?
>> What are your goals for "builtin xml processing in scala" and how does this 
>> relate to your intended use of MarkLogic ?
>> 
>> 
>> -----------------------------------------------------------------------------
>> David Lee
>> Lead Engineer
>> MarkLogic Corporation
>> d...@marklogic.com<mailto:d...@marklogic.com>
>> Phone: +1 812-482-5224
>> Cell:  +1 812-630-7622
>> www.marklogic.com<http://www.marklogic.com>
>> 
>> 
>> 
>> -----Original Message-----
>> From: 
>> general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
>>  
>> [mailto:general-boun...@developer.marklogic.com<mailto:boun...@developer.marklogic.com>]
>>  On Behalf Of David Sargeant
>> Sent: Thursday, October 18, 2012 3:19 PM
>> To: General MarkLogic Developer Discussion
>> Subject: [MarkLogic Dev General] Scala and XCC
>> 
>> I'm farily new to the world of Java/Scala and MarkLogic, so forgive me if 
>> the question seems trivial.  I'm wondering what the best way is to use 
>> MarkLogic and Scala so that I can take advantage of the built-in xml 
>> processing capabilities of Scala?  Thanks.
>> 
>> 
>> David
>> _______________________________________________
>> General mailing list
>> General@developer.marklogic.com<mailto:General@developer.marklogic.com>
>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> General@developer.marklogic.com<mailto:General@developer.marklogic.com>
>> http://developer.marklogic.com/mailman/listinfo/general
> 
> _______________________________________________
> General mailing list
> General@developer.marklogic.com<mailto:General@developer.marklogic.com>
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General@developer.marklogic.com<mailto:General@developer.marklogic.com>
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General@developer.marklogic.com<mailto: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

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to