1
votes

I am building an app, where I need to transform all files in what is $xml below from xml to html, with a certain xslt, obviously. Then I want them to be output as <li> <!-- the transformed output --> </li>

  declare function app:XMLtoHTML-forAll ($node as node(), $model as map(*), $query as xs:string?){
    let $ref := xs:string(request:get-parameter("document", ""))
    let $xml := doc(concat("/db/apps/BookOfOrders/data/edition/",$ref))
    let $xsl := doc("/db/apps/BookOfOrders/resources/xslt/xmlToHtml.xsl")
    let $params :=
    <parameters>
       {for $p in request:get-parameter-names()
        let $val := request:get-parameter($p,())
        where  not($p = ("document","directory","stylesheet"))
        return
           <param name="{$p}"  value="{$val}"/>
       }
    </parameters>
       for $doc in collection("/db/apps/BookOfOrders/data/edition")/tei:TEI

            return

            <li> {transform:transform($xml, $xsl, $params)} </li>
    }; 

My function, however, returns empty <li></li>-elements for every document, I have in this folder. Can anyone hint me towards what I am doing wrong?

Small Edit: it also does not use all files, but only what seems to be randomly pick one and transform this over and over ...

1

1 Answers

1
votes

I would first verify what is being assigned to $xml

let $xml := doc(concat("/db/apps/BookOfOrders/data/edition/",$ref))

and compare that to what is being assigned to $doc in your for loop:

for $doc in collection("/db/apps/BookOfOrders/data/edition")/tei:TEI

Why iterate through each $doc and then transform the same $xml?

<li> {transform:transform($xml, $xsl, $params)} </li>

Did you intend to transform the $doc instead? Maybe also use the $ref to construct the collection URI??