Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • boss98 8 posts 29 karma points
    May 04, 2011 @ 09:39
    boss98
    0

    How to tranform xml tag with xslt

    I have problem.

    Every xml tag  <PropertyDescription> have 2 tags like this

    <PropertyDescriptions>
            <PropertyDescription>
              <DescriptionText>.....DATA ......</DescriptionText>
              <DescriptionType DescriptionType="4" />
            </PropertyDescription>
            <PropertyDescription>
            <DescriptionText>2 SOBNO STANOVANJE NA TABORU</DescriptionText>
              <DescriptionType DescriptionType="6" />
            </PropertyDescription>
          </PropertyDescriptions>

     

    How can I transform them in this tags:

    <Title>2 SOBNO STANOVANJE NA TABORU</title>

    <DATATYPE> .....DATA..... </DATATYPE>

     

    Please help me!


     

     

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    May 04, 2011 @ 12:35
    Jan Skovgaard
    0

    Hi Boss98

    You can transform those elements into the new elements just like you would if you needed the output to be HTML tags like <h1>, <div> etc.

    I suppose that the above XML is what umbraco has generated for you?

    Then you should be able to do something like this

    <title><xsl:value-of select="$currentPage/PropertyDescriptions/DescriptionText" /></title>

    Is this what you're after?

    /Jan

  • boss98 8 posts 29 karma points
    May 04, 2011 @ 12:58
    boss98
    0

    no,Jan. I tried like this:

    <xsl:template match="PropertyDescriptions/PropertyDescription">
        <xsl:for-each select=".">
            <xsl:element name="Title{@DescriptionType}"><xsl:value-of select="DescriptionText" />
            </xsl:element>
            </xsl:for-each></xsl:template>

     

    and <xsl:apply-templates select="PropertyDescriptions/PropertyDescription" />

     

    I expect this results:


    <Title4>2 SOBNO STANOVANJE NA TABORU</Title4>

    <Title6>.....DATA.....</Title6>

     

    But I didn't get it. The results was:

     

    <Title>2 SOBNO STANOVANJE NA TABORU</Title>

    <Title>.....DATA.....</Title>

     

    when I tried this:

    <xsl:template match="PropertyDescriptions/PropertyDescription">
        <xsl:for-each select="
    DescriptionType">
            <xsl:element name="Title{@DescriptionType}"><xsl:value-of select="DescriptionText" />
            </xsl:element>
            </xsl:for-each></xsl:template>

    I get only this:

    <Title4/>
    <Title6>

    What I doing wrong????


  • boss98 8 posts 29 karma points
    May 05, 2011 @ 13:08
    boss98
    0

    Can anyone know to help me?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies