Subject: [xsl] bug in LibXSLT??? From: S Woodside <sbwoodside@xxxxxxxxx> Date: Wed, 5 Mar 2003 22:46:27 -0500 |
============================================= ============================================= file: input.xml ============================================= ============================================= <?xml version="1.0"?> <grammar xmlns:dyn="http://exslt.org/dynamic"> <start> <element name="resume"> <optional> <attribute name="id"> <data type="ID"/> </attribute> </optional> <empty/> <empty/> <optional> <attribute name="xsi:schemaLocation"/> </optional> <optional/> <optional> <element name="header"> <optional> <element name="address"> <optional> <attribute name="format"> <choice> <value> standard </value> <value> european </value> <value> italian </value> </choice> </attribute> </optional> </element> </optional> </element> </optional> </element> </start> </grammar>
============================================= ============================================= file: rng2mid.xsl ============================================= ============================================= <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn" >
<xsl:param name="AddXPath">DEFAULT</xsl:param> <xsl:param name="AddType">DEFAULT</xsl:param> <xsl:param name="AddContent">DEFAULT</xsl:param>
<!--******************************--> <!--******************************--> <!--******************************--> <!--******************************--> <!--******************************--> <!--Normal templates --> <!--******************************-->
<!--******************************--> <!--Root block-->
<xsl:template match="start"> <xsl:apply-templates/> </xsl:template>
<!--******************************--> <!--Dynamic blocks-->
<xsl:template match="zeroOrMore"> <zeroormore> <xsl:call-template name="SimplyRecurse"/> </zeroormore> </xsl:template>
<xsl:template match="oneOrMore"> <oneormore> <xsl:call-template name="SimplyRecurse"/> </oneormore> </xsl:template>
<!--******************************--> <!--Conditional blocks-->
<xsl:template match="choice"> <multi-choice> <xsl:call-template name="SimplyRecurse"/> </multi-choice> </xsl:template>
<xsl:template match="choice/asdf"> <choice> <node><xsl:value-of select="name()"/></node> <path> <xsl:call-template name="RNGPathToSelf"/> </path> <ident><xsl:value-of select="@name"/></ident> <!--<xsl:apply-templates/>--> <xsl:call-template name="SimplyRecurse"/> </choice> </xsl:template>
<xsl:template match="value"> <value> <path> <xsl:call-template name="RNGPathToSelf"/> </path> <xsl:call-template name="SimplyRecurse"/> </value> </xsl:template>
<xsl:template match="optional"> <optional> <path> <xsl:call-template name="RNGPathToSelf"/> <!--<xsl:call-template name="RNGNameOfNearestChild"/>--> </path> <xsl:call-template name="SimplyRecurse"/> </optional> </xsl:template>
<!--******************************--> <!--Basic blocks-->
<xsl:template match="rngsub_stopped"> <prune-point> <insert-into> <xsl:value-of select="@location"/> </insert-into> <i><xsl:value-of select="@location"/></i> </prune-point> </xsl:template>
<xsl:template match="element"> <xsl:if test="not(text)"> <xsl:call-template name="RNGPathToSelf"/> </xsl:if> <xsl:call-template name="SimplyRecurse"/> </xsl:template>
<!--******************************--> <!--Terminating blocks-->
<xsl:template match="text"> <xsl:call-template name="TextEntryArea"/> </xsl:template>
<xsl:template match="attribute"> <xsl:choose> <xsl:when test="not(./*) or ./empty"> <!--no children--> <xsl:call-template name="TextEntryArea"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="SimplyRecurse"/> </xsl:otherwise> </xsl:choose> </xsl:template>
<xsl:template match="data"> <xsl:call-template name="TextEntryArea"/> <!--should check for param children--> </xsl:template>
<!--TODO--> <xsl:template match="group"/>
<!--******************************--> <!--******************************--> <!--******************************--> <!--******************************--> <!--******************************--> <!--Named templates --> <!--******************************-->
<!--******************************--> <!--HTML Forms labels and inputs-->
<!--******************************--> <!--Names of ancestors/descendants-->
<xsl:template name="RNGNameOfAncestorOrSelfTemplate"> <xsl:text><</xsl:text> <xsl:value-of select="ancestor-or-self::* [self::element or self::attribute][@name][1]/@name"/> <xsl:text>></xsl:text> </xsl:template>
<xsl:template name="RNGPathToSelf"> <xsl:for-each select="ancestor-or-self::*/@name"> <xsl:text>/</xsl:text> <xsl:value-of select="."/> </xsl:for-each> </xsl:template>
<xsl:template name="RNGNameOfNearestChild"> <xsl:text>/</xsl:text> <xsl:value-of select="descendant-or-self::* [self::element or self::attribute][@name][1]/@name"/> </xsl:template>
<xsl:template name="RNGPathToParent"> <xsl:for-each select="ancestor::*/@name"> <xsl:text>/</xsl:text> <xsl:value-of select="."/> </xsl:for-each> </xsl:template>
<!--******************************--> <!--Misc-->
<!--******************************--> <!--******************************--> <!--******************************--> <!--******************************--> <!--******************************--> <!--Discard --> <!--******************************--> <xsl:template match="define"/> </xsl:stylesheet>
============================================= ============================================= OUTPUT from LibXSLT (with error) ============================================= =============================================
% xsltproc rng2mid.xsl input.xml <?xml version="1.0"?> <dummy xmlns:dyn="http://exslt.org/dynamic"> <rngform xmlns="mynms"><title>RNG Form</title>
</rngform> </dummy>
============================================= ============================================= OUTPUT from Sablotron (correct) ============================================= ============================================= % sabcmd rng2mid.xsl 2.xml <?xml version="1.0" encoding="UTF-8"?> <dummy> <ns_1:rngform xmlns:ns_1="mynms"> <title>RNG Form</title>
/resume {{{4}}} <optional> <path>/resume</path> {{{5}}} {{{6}}} <text-entry-area> <add-info> <path>/resume/id</path> <type>ID</type> </add-info> <prefilled-value><id></prefilled-value> <description> <label>/resume/id</label> <type>ID</type> </description> </text-entry-area>
</ns_1:rngform> </dummy>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] line-breaking and hyphena, W. Eliot Kimber | Thread | Re: [xsl] bug in LibXSLT???, Daniel Veillard |
[xsl] XSLT Consulting Market?, hnorris norris | Date | [xsl] Re: two cols in one table (a , Dimitre Novatchev |
Month |