I have an XML document that I would like to convert to HTML. I am using Xquery with Oxygen parser for this.
This is the xml:
<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="file:textbook.rnc" type="compact"?>
<books xmlns="books">
<book ISBN="i0321165810" publishername="OReilly">
<title>XPath</title>
<author>
<name>
<fname>Priscilla</fname>
<lname>Warnley</lname>
</name>
<address>
<street_address>Hill Park<street_address>
<zip>90210</zip>
<state>california</state>
</address>
<phone>00000000</phone>
<e-mail>[email protected]</e-mail>
</author>
<year>2007</year>
<field>Databases</field>
<TOC>
<component>
<type>Part</type>
<title>Xpath</title>
<component>
<title>Chapter... A tour of xquery</title>
<pages>3</pages>
<component>
<title>Introductions</title>
</component>
<component>
<title>Getting started</title>
</component>
</component>
</component>
</TOC>
</book>
<publisher publishername="OReilly">
<web-site>www.oreilly.com</web-site>
<address>
<street_address>hill park</street_address>
<zip>90210</zip>
<state>california</state>
</address>
<phone>400400400</phone>
<e-mail>[email protected]</e-mail>
<contact>
<field>Databases</field>
<name>
<fname>Anna</fname>
<lname>Smith</lname>
</name>
</contact>
</publisher>
</books>
I first do this Xquery query:
declare default element namespace "books";
<html>
<head>
<title>Table of contents</title>
</head>
<body>
<b>Table of contents</b>
<hr/>
{ for $i in //book[@ISBN='i0321165810']/TOC
return $i
}
</body>
</html>
based on my xml document get these results:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="Books">
<head>
<title>Table of content</title>
</head>
<body>
<b>TOC</b>
<hr/>
<TOC>
<component>
<type>Part</type>
<title>Foundations</title>
<component>
<title>Chapter... A tour of xquery</title>
<pages>3</pages>
<component>
<title>Introductions</title>
</component>
<component>
<title>Getting started</title>
</component>
</component>
</component>
</TOC>
</body>
</html>
What I would like to do now is replace the component tag with a pre tag (using spaces for indentation), the title tag with an italics tag and the pages tag with a bold tag (basically use HTML tags instead of XML tags, so the document can be viewed in a web browser). I tried to use the replace function, but I could not get it to work.
Could someone please help?