Example XML code with PL/SQL code segments
<?xml version="1.0"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
<ORACLE>
select * from scott.dept;
</ORACLE>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
<CD>
<TITLE>Greatest Hits</TITLE>
<ARTIST>Dolly Parton</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>RCA</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1982</YEAR>
<ORACLE>
begin
htp.p('This is the test data');
end;
</ORACLE>
</CD>
<CD>
<TITLE>Still got the blues</TITLE>
<ARTIST>Gary Moore</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Virgin records</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1990</YEAR>
</CD>
</CATALOG>
Without an XSL style sheet, if you tried to display the above XML code in a browser, you would get something like the following:
So, the XML database portlet Wizard allows you to specify XSL code to apply to your XML, so that it displays appropriately in a browser. For example, you could apply the following to the XML code above.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Dynamic Content</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="ARTIST"/></td>
<td><xsl:value-of select="ORACLE"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Using this style sheet gives you the following:
You can optionally specify DTD code for your XML database portlet that verifies the XML code against a corporate or group-wide standard. This way, you can make sure that any XML code supplied adheres to any rules or standards that you require.
For example, you could include the following DTD code to verify the XML code above.
<!DOCTYPE CATALOG [
<!ELEMENT CATALOG (CD*)
<!ELEMENT CD (TITLE,ARTIST,COUNTRY,COMPANY,PRICE,YEAR,ORACLE)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT ARTIST (#PCDATA)>
<!ELEMENT COUNTRY (#PCDATA)>
<!ELEMENT COMPANY (#PCDATA)>
<!ELEMENT PRICE (#PCDATA)>
<!ELEMENT YEAR (#PCDATA)>
<!ELEMENT ORACLE (#PCDATA)>
]>
This DTD defines that wherever the CATALOG element is used in the XML code, it should consist of one or more CD elements. Likewise, whenever the CD element is used, it should include the TITLE, ARTIST, COUNTRY, COMPANY, PRICE, YEAR, and ORACLE elements.
What are XML database portlets?