Package au.com.test
public class Cube{
private int _sideLength;
// Constructor Method
public Cube(int sideLength){
_sideLength = sideLength;
}
public String GetSurfaceArea(){
int surfaceArea = _sideLength * _sideLength * 6;
return String.valueOf(surfaceArea);
}
public String GetVolume(){
int volume = _sideLength * _sideLength * _sideLength;
return String.valueOf(volume);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cube="au.com.test.Cube">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="SIDE_LENGTH" select="3"/>
<xsl:template match="/">
<xsl:variable name="instance" select="cube:new($SIDE_LENGTH)"/>
<xsl:element name="CubeInfo">
<xsl:element name="SurfaceArea">
<xsl:value-of select=“cube:GetSurfaceArea($instance)"/>
</xsl:element>
<xsl:element name="Volume">
<xsl:value-of select=“cube:GetVolume($instance)"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |