turugina #7179(2008/08/17 20:02 GMT) [ XSLT ] Rating1/1=1.00
XPath の conditional expressions(if then else) など使ってみる。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" > <xsl:output method="text" /> <xsl:variable name="goal" as="xs:string" select="'300'" /> <xsl:template match="/" > <xsl:variable name="digit" as="xs:integer" select="fn:string-length($goal)" /> <xsl:for-each select="1 to $digit"> <xsl:variable name="d" as="xs:integer" select="." /> <xsl:for-each select="(if (.=1) then 0 else 1) to (if (.=$digit) then xs:integer(fn:substring($goal,1,1)) else 9)" > <xsl:value-of select="." /> <xsl:for-each select="2 to $d"> <xsl:value-of select="0" /> </xsl:for-each> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Rating1/1=1.00-0+
[ reply ]
turugina
#7179()
[
XSLT
]
Rating1/1=1.00
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" > <xsl:output method="text" /> <xsl:variable name="goal" as="xs:string" select="'300'" /> <xsl:template match="/" > <xsl:variable name="digit" as="xs:integer" select="fn:string-length($goal)" /> <xsl:for-each select="1 to $digit"> <xsl:variable name="d" as="xs:integer" select="." /> <xsl:for-each select="(if (.=1) then 0 else 1) to (if (.=$digit) then xs:integer(fn:substring($goal,1,1)) else 9)" > <xsl:value-of select="." /> <xsl:for-each select="2 to $d"> <xsl:value-of select="0" /> </xsl:for-each> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet>Rating1/1=1.00-0+
[ reply ]