About Me

My photo
Programming is my passion

Wednesday, April 27, 2011

XML Process TASK

Xml Task:-The XML task is used when you need to validate, modify, extract or even create files in an xml format
Let’s create Package which will validate xml against xsd.
1)First we will two file one XML file which will validate another is XSD which will use to validate document

a) XML File content

b) XSD file content


2) Open BIDS(Business intelligence development studio)
3) Drag XML Task from tool box to Control Flow tab as shown below screen shot

4) Double click on XML Task XML Task editor window will be open

5) On the right there is property called “Operation Type” which define what type of operation will be perform by XML TASK. below is description of operation type values
a) Validate:-Validate and XML against XSD
b) XSLT :- Transform data into presentation format
c) XPath:-This option XML path language allows the extraction of
section or specific nodes from the structure of XML
document
d) Merge :- This option allow to merge two xml document with the
same structure
e) Diff:- This option use to identify the difference between two XML
Document and base on that produce the third document
called XML Diffgram that contain the difference between
the two
f) Patch:-This option applies the results of a diff operation to an xml
document to create a new xml document
6) Choose “Validate” option , There are three option in SourceType
a) FileConnection:-Xml file connection name
b) Direct Input:- Specify direct xml content
c) Variable:-Specify variable name which contain file path
We will use “File connection” option but before that we will create File
connection right click on “Connection Manager” select “New File Connection “ as mentioned below


File Connection manager editor will be open, Specify XML document path which need to validate



Same create for “XSD” (which will use to validate XML document)and “OutputFile”(For storing validation output) connection


7)Specify XML document content Connection value in source type property



8) Specify OutPut connection values in Destination property

9) Specify XSD connection values in “Second Operand” property

Set “ValidationType” property value “XSD” above screen shot because we are validating document against XSD
10) Now all property set we will execute package using F5” validation will be
Success


11) Change the sequence child element from XML document mentioned above

12) Run the Package


13) Open Output.xml file which will contain “false” value

14) If you will go to “Execution Result” panel we can see validation error




Let find Difference between to XML files
1) First we Need to create two XML files
a) XMLOnefile

b) XMLTwofile

If you will see above mentioned I have just changed sequence of child elements.
2) Set “Operation Type” property value “Diff”

3) Set three file connection as set above
a) One is for Source
b) Second is for Destination
c) Third for OutPut.xml

4) Run Package suing F5 button

5) Open Output.xml file you will get false mean xml is not proper

6) Change sequence then run you will get “true” in output.xml file

No comments:

Post a Comment