Thanks Greet I have made some head way after seeing your response. I just save
the file as transformaed.xhtml INSTEAD of transformed.html and it started
working. Below is the code that is now working in query console
let $x := xdmp:xslt-invoke("/pipelines/HTML.xsl",
doc("/ancillary/20130626114719392MXENM08AAS2X_SE_080_03.xml"))
return xdmp:document-insert('/ancillary/html/transformaed.xhtml', $x,
xdmp:default-permissions(), () )
Now when I am integrating this approach in CPF I am back to the same problem
where all the html tags are getting stripped out. Below is the action file for
my pipeline. I have tried using xsl:output and it does not seem to help. When I
use xdmp:quote it starts throwing error.
import module namespace cpf = "http://marklogic.com/cpf" at
"/MarkLogic/cpf/cpf.xqy";
import module namespace ingest = "http://hmhpub.com/ingest" at
"/common/hmh-ingest.xqy";
declare variable $cpf:document-uri as xs:string external;
declare variable $cpf:transition as node() external;
if (cpf:check-transition($cpf:document-uri, $cpf:transition)) then
try {
xdmp:log(fn:concat('try1', doc($cpf:document-uri))),
let $transform := xdmp:quote(xdmp:xslt-invoke("/pipelines/HTML.xsl",
doc($cpf:document-uri)))
return
xdmp:document-insert( '/ancillary/html/transformaed.xhtml', $transform,
xdmp:default-permissions(), () ),
cpf:success($cpf:document-uri, $cpf:transition, ())
}
catch ($e) {
xdmp:log($e),
cpf:failure($cpf:document-uri, $cpf:transition, $e, ())
}
else (
xdmp:log('Nothing')
)
————————————————
Kashif Khan, PMI-ACP
Sr. Solution Architect
Publishing Technology
Houghton Mifflin Harcourt
9400 South Park Center Loop
Orlando, FL 32819
Office: 407.345.3420
Mobile: 407.949.4697
hmhco.com
From: Geert Josten <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Thursday, July 11, 2013 1:00 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Applying XSLT on XML file using
xdmp:xslt-invoke
Hi Kashif,
My first guess would be that your stylesheet returns the output as element
nodes rather than a serialized string, and document-insert assumes .html files
should be stored as text files (which is the default), and therefore flattens
the output from xml to text, effectively stripping all tags.
Depending on what you actually want to do with the stored documents, you can
try to use xsl:output to set the output method to ‘html’. That should force the
xslt to serialize the output, but xsl:output could be ignored altogether, not
sure. If that doesn’t help you can use xdmp:quote to force serialization
yourself. If you actually prefer to keep the xml structure, just pick an
extension who’s mime-type is tied to the xml format, for instance .xhtml..
Kind regards,
Geert
Van:[email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>]
Namens Khan, Kashif
Verzonden: woensdag 10 juli 2013 21:11
Aan: MarkLogic Developer Discussion
Onderwerp: [MarkLogic Dev General] Applying XSLT on XML file using
xdmp:xslt-invoke
Hello everyone, I am having problem understanding the following issue. Any help
will be greatly appreciated
When I use the following code in query console the XSL gets applied and I get
the proper results
let $x := xdmp:xslt-invoke("/pipelines/HTML.xsl",
doc("/ancillary/20130626114719392MXENM08AAS2X_SE_080_03.xml"))
return $x
OUTPUT
<html xmlns="http://www.w3.org/1999/xhtml">
<title>HTML Transformation</title>
<p xmlns="">
<img src="images/MNMTPG2_SE_062_3T_V1_ANS.jpg" alt=""/>
<p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">
<span xmlns="http://www.harcourt.com/HSP">
<math:math>
<math:munder accentunder="true">
<math:mn>5</math:mn>
<math:mo stretchy="true">_</math:mo>
</math:munder>
<math:mn>9</math:mn>
</math:math>
</span>
</p>
<p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">What is the value of the
underlined digit?</p>
</p>
<input type="radio" value="a" xmlns="">5<br/></input>
<input type="radio" value="b" xmlns="">30<br/></input>
<input type="radio" value="c" xmlns="">50<br/></input>
<input type="radio" value="d" xmlns="">900<br/></input>
<input type="submit" name="submit" xmlns=""/>
</html>
But when I try to insert the output into a document I am NOT getting the
expected results
let $x := xdmp:xslt-invoke("/pipelines/HTML.xsl",
doc("/ancillary/20130626114719392MXENM08AAS2X_SE_080_03.xml"))
return xdmp:document-insert( '/ancillary/html/transformaed.html', $x,
xdmp:default-permissions(), () )
OUTPUT:
Here is what I find when I look at the source of transformed.html file. There
are no tags just see extracted text below.
HTML Transformation 5 _ 9 What is the value of the underlined digit?53050900
————————————————
Kashif Khan, PMI-ACP_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general