XSLT Newbie: Attribute Value transformed to Attribute Name

Discussion in 'XML' started by bprimuslevy, Aug 23, 2006.

  1. bprimuslevy

    bprimuslevy Guest

    I have an XML Document that looks like this...
    <UserPermission>
    <Permission Desc="DoSomething" Assigned="1" />
    <Permission Desc="CanAlsoDo" Assigned="1"/>
    </UserPermission>

    I would like to transform the document to look like this...

    <User Permission>
    <Permission DoSomething="1" CanAlsoDo="1"/>
    </UserPermission>

    This is my xslt snippet...
    <xsl:element name="Permission">
    <xsl:for-each select="UserPermission/Permission">
    <xsl:attribute name="@Desc"> <------This is the part that will not
    validate
    <blah blah blah>

    Is what I want to do possible? Does anyone have any sample code?

    Regards,

    BBL
     
    bprimuslevy, Aug 23, 2006
    #1
    1. Advertising

  2. bprimuslevy

    Soren Kuula Guest

    bprimuslevy wrote:
    > I have an XML Document that looks like this...
    > <UserPermission>
    > <Permission Desc="DoSomething" Assigned="1" />
    > <Permission Desc="CanAlsoDo" Assigned="1"/>
    > </UserPermission>
    >
    > I would like to transform the document to look like this...
    >
    > <User Permission>
    > <Permission DoSomething="1" CanAlsoDo="1"/>
    > </UserPermission>
    >
    > This is my xslt snippet...
    > <xsl:element name="Permission">
    > <xsl:for-each select="UserPermission/Permission">
    > <xsl:attribute name="@Desc"> <------This is the part that will not
    > validate
    > <blah blah blah>
    >
    > Is what I want to do possible? Does anyone have any sample code?


    Try to put { } around @Desc. By default, attribute names are taken to be
    literals; putting it into { } will make it an expression (an attribute
    valut template).

    Søren
     
    Soren Kuula, Aug 23, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Moonbeam66
    Replies:
    2
    Views:
    447
    Moonbeam66
    Jun 7, 2005
  2. Philipp Reiss
    Replies:
    4
    Views:
    549
    Manuel Collado
    May 11, 2006
  3. Replies:
    2
    Views:
    446
  4. Stefan_W
    Replies:
    1
    Views:
    8,296
    Stefan_W
    Nov 5, 2008
  5. Curious
    Replies:
    4
    Views:
    108
    Curious
    Feb 14, 2004
Loading...

Share This Page