XSLT Help Needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrgotshot
    New Member
    • Feb 2007
    • 1

    XSLT Help Needed

    Hi I'm new to XSL and am trying to transform so that if both Company and Person details are provided, only the Company details are transformed, also if the Company Name is NULL or of Zero length, only the Person details are transformed:

    I'm trying to use the code segment below, but I just can't seem to get it to work.

    Could someone please assist me.

    Thanks In Advance
    John

    Code:
    <ClientName>
        <StructuredName>
            <xsl:if test="'./CompanyName'!=''">
                <xsl:apply-templates select="xx:CompanyName"/>
            </xsl:if>
            <xsl:if test="'./CompanyName'=''">
    	    <xsl:apply-templates select="xx:Title"/>
                <xsl:apply-templates select="xx:FirstName"/>
                <xsl:apply-templates select="xx:MiddleName"/>
                <xsl:apply-templates select="xx:LastName"/>
            </xsl:if>
        </StructuredName>
    </ClientName>
     
     
    <xsl:template match="xx:CompanyName">
        <StructuredCompanyName>
            <xsl:value-of select ="."/>
        </StructuredCompanyName>
    </xsl:template>
    <xsl:template match="xx:Title">
        <StructuredNameTitle>
            <xsl:value-of select ="."/>
        </StructuredNameTitle>
    </xsl:template>
    <xsl:template match="xx:FirstName">
        <StructuredFirstName>
            <xsl:value-of select ="."/>
        </StructuredFirstName>
    </xsl:template>
    <xsl:template match="xx:MiddleName">
        <StructuredMiddleName>
            <xsl:value-of select ="."/>
        </StructuredMiddleName>
    </xsl:template>
    <xsl:template match="xx:LastName">
        <StructuredLastName>
            <xsl:value-of select ="."/>
        </StructuredLastName>
    </xsl:template>
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    Did you find a solution?

    If not, could you include some XML data too?

    Comment

    • dorinbogdan
      Recognized Expert Contributor
      • Feb 2007
      • 839

      #3
      Hi,
      Did you succeed to solve the problem ?
      If yes, please let me know, in order to close the thread.
      Thanks,
      Dorin.

      Comment

      Working...