Hi, hoping somebody could help me please.
I'm attempting in 10g to convert a XML purchase-order with multiple detail lines to a CSV delimited output using an XSLT to undertake the transformation. Each line of the purchase-order, namely the header and each detail line must go on separate lines within the CSV file. This means each line must be clearly terminated with a CR-LF.
While I can happily convert the XML purchase-order to CSV format, my experiments in inserting a CR-LF have failed, resulting in all lines collapsed onto one large line.
According to various sources on the Net, inserting the following entry in my XSLT file should generate the new line that I'm looking for:
<xsl:text>ampersand#xa;</xsl:text>
(In the above code replace the text "ampersand" with an actual & - I'm unable to display the proper ampersand hash value xa as this HTML page renders it as newline character)
However with no success.
The sample program below shows the conversion process. Anybody any idea on why I'm not seeing the output with new lines?
Your help appreciated.
CM.
DECLARE
v_xml XMLType;
v_xml2 XMLTYPe;
v_xslt XMLType;
BEGIN
v_xml := XMLType(
'<?xml version="1.0" encoding="UTF-8"?>
<PurchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd gatewayPurchaseOrder.xsd"
xmlns="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd">
<Header>
<GatewayPurchaseOrderNo>1234</GatewayPurchaseOrderNo>
<PharmacyReference>2345</PharmacyReference>
</Header>
<Detail>
<ProductNo>9876</ProductNo>
<APNNo>7654</APNNo>
</Detail>
<Detail>
<ProductNo>8888</ProductNo>
<APNNo>7777</APNNo>
</Detail>
</PurchaseOrder>');
v_xslt := XMLType(
'<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd">
<xsl:output method="text"/>
<xsl:template match="/PurchaseOrder/Header">
<xsl:value-of select="normalize-space(GatewayPurchaseOrderNo)"/>,<xsl:value-of select="normalize-space(PharmacyReference)"/>
<xsl:text>ampersand #xa;</xsl:text>
</xsl:template>
<xsl:template match="/PurchaseOrder/Detail">
<xsl:value-of select="normalize-space(ProductNo)"/>,<xsl:value-of select="normalize-space(APNNo)"/>
<xsl:text>ampersand#xa;</xsl:text>
</xsl:template>
</xsl:stylesheet>');
v_xml2 := v_xml.transform(v_xslt);
dbms_output.put_line(v_xml2.getclobval);
END;
(In the above code replace the text "ampersand" with an actual & - I'm unable to display the proper ampersand hash value xa as this HTML page renders it as newline character)