diff xslt/text-tools.xsl @ 0:cbdada054b4a

Basic schemas for generating csharp internal dom from model definition
author cin
date Wed, 21 Feb 2018 03:01:53 +0300
parents
children 7f803979305f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xslt/text-tools.xsl	Wed Feb 21 03:01:53 2018 +0300
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+	<!-- TEXT ROUTINES -->
+	<xsl:template name="write-line">
+		<xsl:param name="level" select="0" />
+		<xsl:param name="text" />
+		<xsl:call-template name="indent">
+			<xsl:with-param name="level" select="$level" />
+		</xsl:call-template>
+		<xsl:value-of select="$text" />
+		<xsl:text>&#xa;</xsl:text>
+	</xsl:template>
+
+	<xsl:template name="indent">
+		<xsl:param name="level" select="0" />
+		<xsl:if test="$level > 0">
+			<xsl:text>    </xsl:text>
+			<xsl:call-template name="indent">
+				<xsl:with-param name="level" select="$level - 1" />
+			</xsl:call-template>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template name="to-lower-first">
+		<xsl:param name="value" />
+		<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
+		<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
+		<xsl:variable name="before" select="substring($value,1,1)" />
+		<xsl:variable name="after" select="substring($value,2)" />
+		<xsl:value-of
+			select="concat(translate($before,$uppercase,$smallcase), $after)" />
+	</xsl:template>
+
+	<xsl:template name="to-lower">
+		<xsl:param name="value" />
+		<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
+		<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
+		<xsl:value-of select="translate($value,$uppercase,$smallcase)" />
+	</xsl:template>
+</xsl:stylesheet>
\ No newline at end of file