Using XQuery to create valid Latex file based on XML data

watkinspig

New Member
I know this task is somewhat unorthodox, but I hope someone is able to help me. I'm trying to create a valid Latex file using XQuery, based on XML file on products. The XML file (xml/products.xml) looks like this:\[code\]<?xml version="1.0"?><Products> <Maker name = "A"> <PC model = "1001" price = "2114"> <Speed> 2.66 </Speed> <RAM> 1024 </RAM> <HardDisk> 250 </HardDisk> </PC>\[/code\]This is the latex output I need:\[code\]\documentclass[]{article}\begin{document}\begin{center}\begin{tabular}{| l | l |}\hlinePrice & Model \\ \hlineprice value & model value \\ \hline\end{tabular}\end{center}\end{document}\[/code\]And I've created the following (character escaping) XQuery to produce the required Latex:\[code\]let $oc := "{" (: for { :)let $cc := "}" (: for } :)let $space := " " (: space :)let $tab := " " (: tab :)let $ampersand := "&" (: ampersand :)\\documentclass\[\]{$oc}article{$cc}\\begin{$oc}document{$cc}\\begin{$oc}center{$cc} \\begin{$oc}tabular{$cc}{$oc}| l | l |{$cc} \\hline Model{$ampersand}Price{$space}\\\\{$space}\\hline {for $pc in doc("xml/products.xml")/Products/Maker/PClet $price:=data($pc/@price)let $model:=data($pc/@model)return{$model}{$ampersand}{$price} \\\\ \\hline}\\end{$oc}tabular{$cc}\\end{$oc}center{$cc}\\end{$oc}document{$cc}\[/code\]I can't get the query to work.. :(. And as usual, XQuery does not give much debug info to go on. Are there smarter ways of escaping characters using XQuery? Or perhaps just printing text directly?
 
Back
Top