Quote:
quote:Originally posted by mhkay
Sorry, without knowing anything about your system or seeing any code it's quite impossible to debug this.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
Hi Michael,
please go through this code..this is the XSL..pls see if any error is there..
<?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" indent="yes" cdata-section-elements="script" />
- <xsl:template match="*|@*|text()|comment()">
- <xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:copy>
</xsl:template>
- <!-- Matches the person tag containing all information about the logged in user.
First all notes fields are parsed in a for loop, next all the dynamic userdefined
fields are parsed.
-->
- <xsl:template match="person" xmlns:coloplastFunctions="xalan://com.coloplast.web.fillform2.classes.resources.Pars eXMLwithStylesheet">
- <xsl:for-each select="./*[@fieldref!='']">
- <!-- Match input elements
-->
- <xsl:call-template name="create_text_input">
- <xsl:with-param name="match">
field[starts-with(@notestype,'
<xsl:value-of select="@fieldref" />
')]
</xsl:with-param>
<xsl:with-param name="value" select="." />
</xsl:call-template>
- <!-- Match textarea elements
-->
- <xsl:call-template name="create_textarea">
- <xsl:with-param name="match">
field[starts-with(@notestype,'
<xsl:value-of select="@fieldref" />
')]
</xsl:with-param>
<xsl:with-param name="value" select="." />
</xsl:call-template>
- <!-- Match choice elements
-->
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
field[starts-with(@notestype,'
<xsl:value-of select="@fieldref" />
')]/input[@value='
<xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
']
</xsl:with-param>
<xsl:with-param name="attributename">checked</xsl:with-param>
</xsl:call-template>
- <!-- Match select elements
-->
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
field[starts-with(@notestype,'
<xsl:value-of select="@fieldref" />
')]/select/option[@value='
<xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
']
</xsl:with-param>
<xsl:with-param name="attributename">selected</xsl:with-param>
</xsl:call-template>
- <!-- Static fields SET PROFILE ENTRY TRUE
-->
- <xsl:call-template name="create_profile_attribute">
- <xsl:with-param name="match">
field[starts-with(@notestype,'
<xsl:value-of select="@fieldref" />
')]
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
- <!-- Dynamic TEXT fields
-->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Textfield' or @type='password']">
- <xsl:call-template name="create_text_input">
- <xsl:with-param name="match">
subform[@alias='
<xsl:value-of select="ancestor::FORM/FORMALIAS/." />
']/field[@alias='
<xsl:value-of select="./FIELDALIAS/." />
']
</xsl:with-param>
<xsl:with-param name="value" select="./VALUES/VALUE/." />
</xsl:call-template>
</xsl:for-each>
- <!-- Dynamic TEXTAREA fields
-->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Textarea']">
- <xsl:call-template name="create_textarea">
- <xsl:with-param name="match">
subform[@alias='
<xsl:value-of select="ancestor::FORM/FORMALIAS/." />
']/field[@alias='
<xsl:value-of select="./FIELDALIAS/." />
']
</xsl:with-param>
<xsl:with-param name="value" select="./VALUES/VALUE/." />
</xsl:call-template>
</xsl:for-each>
- <!-- Dynamic RADIO & CHECKBOX fields
-->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Radiobutton' or @type='Checkbox' or @type='ExpandingCategories']/VALUES/VALUE">
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
subform[@alias='
<xsl:value-of select="ancestor::FORM/FORMALIAS/." />
']/field[@alias='
<xsl:value-of select="../../FIELDALIAS/." />
']/input[@value='
<xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
']
</xsl:with-param>
<xsl:with-param name="attributename">checked</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
- <!-- Dynamic EXPANDING CATEGORIES fields
-->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='ExpandingCategories']/VALUES/VALUE">
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
subform[@alias='
<xsl:value-of select="ancestor::FORM/FORMALIAS/." />
']/field[@alias='
<xsl:value-of select="../../FIELDALIAS/." />
']//category[value='
<xsl:value-of select="@category" />
']//input[@value='
<xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
']
</xsl:with-param>
<xsl:with-param name="attributename">checked</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
- <!-- Dynamic SELECT & SELECTMULTI fields
-->
- <xsl:for-each select="./FORM/FIELDS/FIELD[@type='Select' or @type='Selectmulti']/VALUES/VALUE">
- <xsl:call-template name="create_choice_input">
- <xsl:with-param name="match">
subform[@alias='
<xsl:value-of select="ancestor::FORM/FORMALIAS/." />
']/field[@alias='
<xsl:value-of select="../../FIELDALIAS/." />
']/select/option[@value='
<xsl:value-of select="coloplastFunctions:replaceApos(string(.))" />
']
</xsl:with-param>
<xsl:with-param name="attributename">selected</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
- <!-- Dynamic fields SET PROFILE ENTRY TRUE
-->
- <xsl:for-each select="./FORM/FIELDS/FIELD">
- <xsl:call-template name="create_profile_attribute">
- <xsl:with-param name="match">
subform[@alias='
<xsl:value-of select="ancestor::FORM/FORMALIAS/." />
']/field[@alias='
<xsl:value-of select="./FIELDALIAS/." />
']
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
- <!-- Template for inserting xsl that changes the value-attribute of input fields.
This template takes two arguments:
1. match: the x-path expression that locates the input field where the value should
be inserted
2. value: the value to insert.
-->
- <xsl:template name="create_profile_attribute">
<xsl:param name="match" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
<xsl:value-of select="$match" />
</xsl:attribute>
- <xsl:element name="xsl:copy">
- <xsl:element name="xsl:apply-templates">
<xsl:attribute name="select">@*</xsl:attribute>
</xsl:element>
- <xsl:element name="xsl:attribute">
<xsl:attribute name="name">in_profile_registration</xsl:attribute>
<xsl:text>true</xsl:text>
</xsl:element>
- <xsl:element name="xsl:apply-templates">
<xsl:attribute name="select">@*|*|text()</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
- <!-- Template for inserting xsl that changes the value-attribute of input fields.
This template takes two arguments:
1. match: the x-path expression that locates the input field where the value should
be inserted
2. value: the value to insert.
-->
- <xsl:template name="create_text_input">
<xsl:param name="match" />
<xsl:param name="value" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
<xsl:value-of select="$match" />
/input[@type='text' or @type='password']/@value
</xsl:attribute>
- <xsl:element name="xsl:attribute">
<xsl:attribute name="name">value</xsl:attribute>
<xsl:value-of select="$value" />
</xsl:element>
</xsl:element>
</xsl:template>
- <!-- Template for inserting xsl that changes the content of textarea tags.
This template takes two arguments:
1. match: the x-path expression that locates the field where the textarea content should
be inserted
2. value: the value to insert.
-->
- <xsl:template name="create_textarea">
<xsl:param name="match" />
<xsl:param name="value" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
<xsl:value-of select="$match" />
/textarea
</xsl:attribute>
- <xsl:element name="xsl:copy">
- <xsl:element name="xsl:apply-templates">
<xsl:attribute name="select">@*</xsl:attribute>
</xsl:element>
<xsl:value-of select="$value" />
</xsl:element>
- <!-- <xsl:element name="xsl:attribute">
<xsl:attribute name="name">profile</xsl:attribute>
<xsl:text>true</xsl:text>
</xsl:element>
-->
</xsl:element>
</xsl:template>
- <!-- Template for inserting xsl that changes the value-attribute of 'choice' fields.
This template takes two arguments:
1. match: the x-path expression that locates the input field where the value should
be inserted
2. attributename: the 'selected' attribute that indicates the choice has beed seelcted
in Checkbox and Radio button elements it is: 'checked', and in Select and Select Multi
it is: 'selected'.
-->
- <xsl:template name="create_choice_input">
<xsl:param name="match" />
<xsl:param name="attributename" />
- <xsl:element name="xsl:template">
- <xsl:attribute name="match">
<xsl:value-of select="$match" />
</xsl:attribute>
- <xsl:element name="xsl:copy">
- <xsl:element name="xsl:apply-templates">
<xsl:attribute name="select">@*</xsl:attribute>
</xsl:element>
- <xsl:element name="xsl:attribute">
- <xsl:attribute name="name">
<xsl:value-of select="$attributename" />
</xsl:attribute>
<xsl:value-of select="$attributename" />
</xsl:element>
- <xsl:element name="xsl:apply-templates">
<xsl:attribute name="select">@*|*|text()</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>