Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2796

Re: xslt mapping to add schemaLocation and attributes

$
0
0

Hi Asif,

With this source (your original XML has an error in the ns1:ID tag:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:Records NumberOfRecords="1" ChangeTimestamp="2015-11-23T12:15:51.0Z" xmlns:ns1="http://www.xyz.com/storeweaver/records/2.0.0">

    <ns1:Record Type="add">

        <ns1:ID>123456</ns1:ID>

        <ns1:FirstName>Test</ns1:FirstName>

        <ns1:LastName>Test</ns1:LastName>

        <ns1:Language>EN</ns1:Language>

        <ns1:Address>abc</ns1:Address>

    </ns1:Record>

</ns1:Records>

 

 

With this XSL:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:stylesheet version="1.0" xmlns:ns0="http://www.w3.org/1999/XSL/Transform">

    <ns0:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <ns0:template match="/">

        <ns1:Records xsi:schemaLocation="http://xyz.com/records/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" NumberofRecords="1" ChangeTimestamp="2015-11-23T12:15:51.0Z" xmlns:ns1="http://www.xyz.com/storeweaver/records/2.0.0">

            <ns0:copy-of select="//ns1:Record"/>

        </ns1:Records>

    </ns0:template>

</ns0:stylesheet>

 

 

I get this XML with the attributes:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:Records xmlns:ns1="http://www.xyz.com/storeweaver/records/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xyz.com/records/2.0.0" NumberofRecords="1" ChangeTimestamp="2015-11-23T12:15:51.0Z">

    <ns1:Record Type="add">

        <ns1:ID>123456</ns1:ID>

        <ns1:FirstName>Test</ns1:FirstName>

        <ns1:LastName>Test</ns1:LastName>

        <ns1:Language>EN</ns1:Language>

        <ns1:Address>abc</ns1:Address>

    </ns1:Record>

</ns1:Records>

 

Regards.


Viewing all articles
Browse latest Browse all 2796

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>