format
This commit is contained in:
parent
db09746609
commit
d5aa66fc35
3 changed files with 15 additions and 20 deletions
|
@ -37,7 +37,6 @@
|
||||||
</xs:restriction>
|
</xs:restriction>
|
||||||
</xs:simpleType>
|
</xs:simpleType>
|
||||||
|
|
||||||
|
|
||||||
<xs:complexType name="Interpretation">
|
<xs:complexType name="Interpretation">
|
||||||
<xs:simpleContent>
|
<xs:simpleContent>
|
||||||
<xs:extension base="InterpElement">
|
<xs:extension base="InterpElement">
|
||||||
|
@ -53,7 +52,6 @@
|
||||||
</xs:simpleContent>
|
</xs:simpleContent>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|
||||||
|
|
||||||
<xs:complexType name="Substitutions">
|
<xs:complexType name="Substitutions">
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="substitution" type="Substitution" maxOccurs="unbounded" />
|
<xs:element name="substitution" type="Substitution" maxOccurs="unbounded" />
|
||||||
|
@ -86,5 +84,4 @@
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
|
|
|
@ -19,5 +19,4 @@
|
||||||
</xs:choice>
|
</xs:choice>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
|
|
31
tortue.xsl
31
tortue.xsl
|
@ -18,19 +18,19 @@
|
||||||
<!-- Substitution -->
|
<!-- Substitution -->
|
||||||
<xsl:template name="substitution">
|
<xsl:template name="substitution">
|
||||||
<xsl:param name="actuel" />
|
<xsl:param name="actuel" />
|
||||||
<xsl:param name="n" />
|
<xsl:param name="n" />
|
||||||
<!-- Si on doit encore substituer -->
|
<!-- Si on doit encore substituer -->
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$n > 0">
|
<xsl:when test="$n > 0">
|
||||||
<!-- Applique la substitution -->
|
<!-- Applique la substitution -->
|
||||||
<xsl:variable name="data">
|
<xsl:variable name="data">
|
||||||
<xsl:call-template name="Application">
|
<xsl:call-template name="Application">
|
||||||
<xsl:with-param name="data" select="$actuel" />
|
<xsl:with-param name="data" select="$actuel" />
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
|
||||||
<!-- Appel récursif -->
|
<!-- Appel récursif -->
|
||||||
<xsl:call-template
|
<xsl:call-template
|
||||||
name="substitution">
|
name="substitution">
|
||||||
<xsl:with-param name="actuel" select="$data" />
|
<xsl:with-param name="actuel" select="$data" />
|
||||||
<xsl:with-param name="n" select="$n - 1" />
|
<xsl:with-param name="n" select="$n - 1" />
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<!-- Interprétation -->
|
<!-- Interprétation -->
|
||||||
<xsl:call-template name="Interpretation">
|
<xsl:call-template name="Interpretation">
|
||||||
<xsl:with-param name="data" select="$actuel" />
|
<xsl:with-param name="data" select="$actuel" />
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
|
@ -48,8 +48,8 @@
|
||||||
<!-- Applique la substitution -->
|
<!-- Applique la substitution -->
|
||||||
<xsl:template name="Application">
|
<xsl:template name="Application">
|
||||||
<xsl:param name="data" />
|
<xsl:param name="data" />
|
||||||
<xsl:variable name="substitution" select="substitutions/substitution" />
|
<xsl:variable name="substitution" select="substitutions/substitution" />
|
||||||
<xsl:analyze-string
|
<xsl:analyze-string
|
||||||
select="$data" regex=".">
|
select="$data" regex=".">
|
||||||
<xsl:matching-substring>
|
<xsl:matching-substring>
|
||||||
<xsl:value-of select="$substitution[@member = current()]" />
|
<xsl:value-of select="$substitution[@member = current()]" />
|
||||||
|
@ -60,14 +60,14 @@
|
||||||
<!-- Interprète la séquence -->
|
<!-- Interprète la séquence -->
|
||||||
<xsl:template name="Interpretation">
|
<xsl:template name="Interpretation">
|
||||||
<xsl:param name="data" />
|
<xsl:param name="data" />
|
||||||
<xsl:variable name="interpretation"
|
<xsl:variable name="interpretation"
|
||||||
select="interpretations/interpretation" />
|
select="interpretations/interpretation" />
|
||||||
<xsl:analyze-string
|
<xsl:analyze-string
|
||||||
select="$data" regex=".">
|
select="$data" regex=".">
|
||||||
<xsl:matching-substring>
|
<xsl:matching-substring>
|
||||||
<xsl:variable name="action"
|
<xsl:variable name="action"
|
||||||
select="$interpretation[@member = current()]" />
|
select="$interpretation[@member = current()]" />
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<!-- Ecrire -->
|
<!-- Ecrire -->
|
||||||
<!-- TODO: Si plusieurs <line /> se suivent on pourrait les additionner -->
|
<!-- TODO: Si plusieurs <line /> se suivent on pourrait les additionner -->
|
||||||
<xsl:when test="matches($action, '^LINE \d+$')">
|
<xsl:when test="matches($action, '^LINE \d+$')">
|
||||||
|
@ -104,10 +104,10 @@
|
||||||
|
|
||||||
<!-- Debug -->
|
<!-- Debug -->
|
||||||
<!-- <xsl:otherwise>
|
<!-- <xsl:otherwise>
|
||||||
<action>
|
<action>
|
||||||
<xsl:value-of select="$interpretation[@member = current()]" />
|
<xsl:value-of select="$interpretation[@member = current()]" />
|
||||||
</action>
|
</action>
|
||||||
</xsl:otherwise> -->
|
</xsl:otherwise> -->
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:matching-substring>
|
</xsl:matching-substring>
|
||||||
</xsl:analyze-string>
|
</xsl:analyze-string>
|
||||||
|
@ -117,8 +117,7 @@
|
||||||
<!-- On récupère le Lsystem qui nous intéresse -->
|
<!-- On récupère le Lsystem qui nous intéresse -->
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<xsl:processing-instruction name="xml-model">href="tortue.xsd"</xsl:processing-instruction>
|
<xsl:processing-instruction name="xml-model">href="tortue.xsd"</xsl:processing-instruction>
|
||||||
<xsl:apply-templates
|
<xsl:apply-templates
|
||||||
select="lsystems/lsystem[name=$nom]" />
|
select="lsystems/lsystem[name=$nom]" />
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
</xsl:transform>
|
</xsl:transform>
|
||||||
|
|
Reference in a new issue