PI: importdbThe purpose of an import PI is to produce an XML-fragment from a database request. <?_wxt importdb connection="" sql="" driver="" xpath="" targetlocation="" transformation=""?> The parameters are:
Styleclass describing a possible table-output from this PI is: dbresult, see distributed std styles. Examples: Importing a fragment of XHTMLcode <?_wxt importdb connection="jdbc:mysql://frigg.hiof.no/fragments?user=a&password=b" sql="use fragments; select content from material where fragid = 3;" encoding="UTF-8" parse="yes" targetlocation="dbdump4.xml"?> Importing and showing the result as a table <?_wxt importdb connection="jdbc:mysql://frigg.hiof.no/vin?user=a&password=b" sql="use vin; select type,name,dice,price from wines where country='Spania' and type='white'; select type,name,dice from wines where country = 'Frankrike' and type='sparkling' and dice=6;" encoding="UTF-8" transformation="_table" xpath="//div[@class='dbresult' and position()='1']" targetlocation="dbdump.xml"?> Note the xpath stating that we will show the first of, in this case, two dbresults. Importing and showing with a written transformation <?_wxt importdb connection="jdbc:mysql://frigg.hiof.no/vin?user=a&password=b" sql="use vin; select type,description,dice,name from wines where country = 'Frankrike';" encoding="UTF-8" transformation="vindb1(type='red',dice='1')" xpath="//div[@id='root']/*" targetlocation="dbdump1.xml"?> |