Welcome to All Things Warehouse Builder

  • ETL
    June 11, 2007

Some tips and hints about (XML) file as target...

Jean-Pierre Dijcks
Master Product Manager

I was playing with the XML as file target in OWB and I noticed some things that are worthwhile mentioning (I thought)... some of these also apply to a generic flat file though...

First things first, if you want to write to file (using the default operator as described here) make sure you understand that we are using UTL_FILE as a mechanism. This means certain things as to how to set up access to directories. More about is in the Oracle documentation on utilities (I think).

Now if you use a file as target, you do NOT have to:

  1. Create a file definition first (provided you are not interested in fancy attribute names etc.)

  2. Synchronize (or create and bind initially) unless you really want to. The reason for doing this is that we will create a file definition for you and it makes lineage more complete (but the code will work without doing this)

What you do need to do is go into mapping configuration and set the data file properties:


All of this information will be used to generate the actual mapping. Not checking the XML box obviously will give you an ASCII output file.

Before we go to the XML case, do be aware of the fact that the file is defined as having as many fields (and seperators) as the file definition in the mapping. So for a regular flat file with this mapping:


You get the following result (Note the last ',' in the file!):


Now if we look at the same mapping, but now creating an XML file (and only for the XML variant) and not mapping an attribute or element in the XML file, you will run into an error upon deployment (PLS-00201: identifier 'NULL$1' must be declared)...

To avoid this and to explicitly model your expected data result (e.g. that last attribute - or any middle attribute in the file) you should create a mapping like this specifically adding a NULL value into the XML file.


That way you will get the following (just a single 'row' in this case):

<?xml version="1.0" ?>








  <STATUS />


Note the 'empty' status part for this XML file...  If you work with the operator this way you will get compiling code and an explicit model of what data you are expecting. If you want to exclude attributes from the file, make sure that you remove the attribute from the definition. Since this is only captured (see first part of the post) in the mapping, this can be done quite quickly and efficiently.

Join the discussion

Comments ( 4 )
  • Erik Ykema Wednesday, July 14, 2010
    Thanks for the hint.
    Can we influence the case of the XML tags, e.g. [CustomerOrder] i.s.o. [CUSTOMERORDER]?
    (I am using [ ] here as the pointy XML tag markers mess up the HTML...
  • David Allan Wednesday, July 14, 2010
    Doesn't look to be any way (the business names could have been used but weren't). You'd have to use the table function as target approach and do it that way.
  • Juha Thursday, November 3, 2011

    When defining XML file as target is there any way to affect the tag: <?xml version="1.0"?> ? It seems that changing characterset from file properties does not affect to this tag. I am using OWB

    I would need something like <?xml version="1.0" encoding="ISO-8859-1"?> or <?xml version="1.0" encoding="windows - 1252"?> so this encoding part is missing and it seems that I cannot tell to OWB how to make that happen automatically...

    Best regards,


  • David Thursday, November 3, 2011

    Hi Juha

    In OWB 11gR2 the encoding can be specified. I don't think this is possible before that release you would have to have your own table function used as a target that writes the XML.

    Like the one mentioned and included in this blog post;




Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.