File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes XSLT needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSLT needed" Watch "XSLT needed" New topic

XSLT needed

N Bhonsle

Joined: Jan 12, 2005
Posts: 13
I have the following xml snippet:
<portlet logLevel="error">
<enablePortlet status="true"></enablePortlet>
<sessionPool maxSessions="20" useCachedSession="true" maxSessionAgeHour="1" maxSessionInactivityPeriodMinute="10"></sessionPool>

I need to write a xsl which transforms the above xml to the following xml--

<portlet logLevel="error" pickerCompatibleVersions="10.1.2" maxDataRows="1000" logLevel="error">
<enablePortlet status="true"/>
<sessionPool maxSessions="20" useCachedSession="true" maxSessionAgeHour="35" maxSessionInactivityPeriodMinute="17" maxRefreshWaitMinute="1" maxRefreshRetries="1" maxGenericParameters="10"
maxNewSessionPerMinute="6" maxWaitNewSessionMinute="30"/>

I wrote the following, but it adds the enablePortlet element and the sessionPool element twice in the resultant file --
<xsl:template match="portlet">
<xsl:attribute name="pickerCompatibleVersions"><xsl:text>10.1.2</xsl:text>
<xsl:attribute name="maxDataRows"><xsl:text>1000</xsl:text></xsl:attribute>
<xsl:copy-of select="@*"/>
<xsl:element name="sessionPool">
<xsl:attribute name="maxRefreshWaitMinute"><xsl:text>1</xsl:text>
<xsl:attribute name="maxRefreshRetries"><xsl:text>1</xsl:text></xsl:
<xsl:attribute name="maxGenericParameters"><xsl:text>10</xsl:text></
<xsl:copy-of select="enablePortlet"/>

What am I doing wrong in the xslt? Can someone please help.

Thanks much.
N Bhonsle

Joined: Jan 12, 2005
Posts: 13
THis is resolved.

I agree. Here's the link:
subject: XSLT needed
Similar Threads
How to avoid spawning new lines when processing?
XSL Problem
XSLT problem.
Adding a new element to xml using xslt
xsl getNext to sort output