how to attribute in xml using xsl?



I am new to xslt and I am struggling to add attribute to my xml. I have seen lots of sites and stack trace but couldn't get my result. Maybe I am missing something. It would be great help if someone can provide me good links related to similar solution or example how to do it. I have my source xml file like this:



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

<entryRoute>
<from uri="direct:entryRoute"/>
<to uri="bean:uuidgen?method=uuidgenrate"/>
</entryRoute>
<Basetransformationroute>
<from uri="direct:Basetransformationroute"/>
<to uri="bean:soSSContextBeanRef?method=updateSoSScontext"/>
</Basetransformationroute>

</baseroutes>


The resultant xml I want to be like this:



<routes>
<route id="entryRoute">

<from uri="direct:entryRoute"/>

<log message="in entry ROute body is this"/>
<log message="requestGUUID header is this"/>

<to uri="bean:uuidgen?method=uuidgenrate"/>

</route>

<!--hazelcast route -->
<route id="hazelcastadd">
<from uri="direct:put"/>
<setHeader headerName="CamelHazelcastOperationType">
<constant>put</constant>
</setHeader>
<setHeader headerName="CamelHazelcastObjectId">
<simple>${in.header.tenantid}-${in.header.requestGUUID}</simple>
</setHeader>
<to uri="hazelcast:multimap:SoSSContextQueue"/>
<log message="after hc $"/>
<to uri="bean:logserver?method=debug($,$,$,$)"/>
</route>

<!--BaseTransformation route -->
<route id="Basetransformationroute">

<from uri="direct:Basetransformationroute"/>


<log message="in entry ROute body is this"/>
<log message="requestGUUID header is this"/>

<to uri="bean:soSSContextBeanRef?method=updateSoSScontext"/>

</routes>


I want from and to tag from source xml to be added as it is into my resultant xml. Right now I am getting from and to into my resultant xml but problem is the attribute node in source file becoming text node in my resultant.


No comments:

Post a Comment