Hi,

Somehow I interpreted your earlier email as that you were trying to manipulate 
the node before sending it to XSLT. It's been a long day :)

Geert's suggestion works. Here's an example of how you can run the XSLT in 
MarkLogic:


xquery version "1.0-ml";

let $doc :=
  <advancedSettings>
  <value>&lt;settings&gt;&lt;setting 
name="asv.preview.maxRows"&gt;450&lt;/setting&gt;&lt;/settings&gt;</value>
  </advancedSettings>

let $xsl :=
  <xsl:template match="value" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:xdmp="http://marklogic.com/xdmp"; version="2.0">
    <xsl:copy>
      <xsl:sequence select="@*"/>
      <xsl:sequence select="xdmp:unquote(.)"/>
    </xsl:copy>
  </xsl:template>

return
  xdmp:xslt-eval($xsl, $doc)

Rob Szkutak
Associate Consultant
MarkLogic Corporation
[email protected]
Cell +1.716.562.8464
www.marklogic.com<http://www.marklogic.com>

________________________________
From: [email protected] 
[[email protected]] on behalf of Gary Larsen 
[[email protected]]
Sent: Tuesday, June 30, 2015 1:28 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] Convert element text to node in XSL

Thanks for the suggestions!

I have an older app and using Saxon for XSL (data is stored in ML).   
Attempting to parse the embedded XML (/name and /setting) to an HTML table.  
The document is generated from serializing a Java bean to XML which is where 
the embedded XML is coming from.

Found that Saxon 9 has a fn:parse-xml() function so think I will try that.

Gary Larsen
Envisn Inc.
508 259-6465

From: [email protected] 
[mailto:[email protected]] On Behalf Of Indrajeet Verma
Sent: Tuesday, June 30, 2015 1:51 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Convert element text to node in XSL

Hi Gary,

Will that work for you OR do you expect anything else?

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema"; exclude-result-prefixes="xs" 
version="2.0">
   <xsl:template match="/">
       <xsl:apply-templates/>
   </xsl:template>

    <xsl:template match="advancedSettings">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="value">
        <xsl:value-of select="." disable-output-escaping="yes"/>
    </xsl:template>
</xsl:stylesheet>

OR

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema"; exclude-result-prefixes="xs" 
version="2.0">

    <xsl:template match="advancedSettings">
        <xsl:value-of select="value" disable-output-escaping="yes"/>
    </xsl:template>

</xsl:stylesheet>

Output:

<settings><setting name="asv.preview.maxRows">450</setting></settings>

Regards,
Indy

On Tue, Jun 30, 2015 at 11:06 PM, Gary Larsen 
<[email protected]<mailto:[email protected]>> wrote:
Thanks Rob,

Is there something I can use in XSL?   Although maybe I can preprocess the 
document before sending to the stylesheet,

Gary Larsen
Envisn Inc.
508 259-6465<tel:508%20259-6465>

From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Rob Szkutak
Sent: Tuesday, June 30, 2015 1:29 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Convert element text to node in XSL

Here you go:

xquery version "1.0-ml";

let $doc :=
<advancedSettings>
<value>&lt;settings&gt;&lt;setting 
name="asv.preview.maxRows"&gt;450&lt;/setting&gt;&lt;/settings&gt;</value>
</advancedSettings>

let $convert := xdmp:unquote(xdmp:url-decode($doc/value/text()))

return
  $convert//setting


Best,
Rob

Rob Szkutak
Associate Consultant
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Cell +1.716.562.8464<tel:%2B1.716.562.8464>
www.marklogic.com<http://www.marklogic.com>

________________________________
From: 
[email protected]<mailto:[email protected]>
 
[[email protected]<mailto:[email protected]>]
 on behalf of Gary Larsen 
[[email protected]<mailto:[email protected]>]
Sent: Tuesday, June 30, 2015 12:27 PM
To: 'General MarkLogic Developer Discussion'
Subject: [MarkLogic Dev General] Convert element text to node in XSL
Hope this isn’t too off topic.  In an XML document the value element contains 
and encoded XML string. I would like to parse this to a node in XSL for further 
processing.

<advancedSettings>
<value>&lt;settings&gt;&lt;setting 
name="asv.preview.maxRows"&gt;450&lt;/setting&gt;&lt;/settings&gt;</value>
</advancedSettings>

Is this possible?

Thanks,
Gary


_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to