Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT Atrtibute Value

Reply
Thread Tools

XSLT Atrtibute Value

 
 
parvus
Guest
Posts: n/a
 
      01-11-2006
Hi, Iīm searching a solution for the following problem:
Iīve a generated XML Document like

<....>
<struct name="number" type="PartNumber">100</struct>
<struct name="identity" type="PartIdentity">1</struct>
<enum name="ex_identity" type="....."></enum>
<....>

Now i want to use a XSLT file to create a new structured XML file like

<....>
<number sort="struct" type="PartNumber">100</struct>
<identity sort="struct" type="PartIdentity">1</struct>
<ex_identity sort="enum" type="........

My problem ist, that i couldnīt read out the value of the attribute
"name" so i canīt
create a new element of it. Furthermore i need to create the other
attributes for the new element or maybe i can copy them easily(?). Does
anybody have any solution? PLZ help me im searching for a long time.

Big THX parvus

 
Reply With Quote
 
 
 
 
Edwin Kapauni
Guest
Posts: n/a
 
      01-11-2006
parvus wrote:
[...]
> Now i want to use a XSLT file to create a new structured XML file like
>
> <....>
> <number sort="struct" type="PartNumber">100</struct>
> <identity sort="struct" type="PartIdentity">1</struct>
> <ex_identity sort="enum" type="........

[...]
Using enum is a good idea. But the above is not well formed XML.
Maybe you want something else?
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      01-11-2006
In article <(E-Mail Removed) .com>,
parvus <(E-Mail Removed)> wrote:

><struct name="number" type="PartNumber">100</struct>


><number sort="struct" type="PartNumber">100</struct>


You want something like

<xsl:element name="{@name}"> ...

-- Richard
 
Reply With Quote
 
parvus
Guest
Posts: n/a
 
      01-11-2006
Big THX for these very fast answers, but

<xsl:element name="{@name}"> ...

doesnīt work thats the problem. Furthermore with "{@name}" i donīt
get the value but the name of the attribute. I need the value. I
searched on www.w3.org but i didnīt find any solution.

 
Reply With Quote
 
Soren Kuula
Guest
Posts: n/a
 
      01-11-2006
Hi,
> Hi, Iīm searching a solution for the following problem:
> Iīve a generated XML Document like
>
> <....>
> <struct name="number" type="PartNumber">100</struct>
> <struct name="identity" type="PartIdentity">1</struct>
> <enum name="ex_identity" type="....."></enum>
> <....>
>
> Now i want to use a XSLT file to create a new structured XML file like
>
> <....>
> <number sort="struct" type="PartNumber">100</struct>
> <identity sort="struct" type="PartIdentity">1</struct>
> <ex_identity sort="enum" type="........
>
> My problem ist, that i couldnīt read out the value of the attribute
> "name" so i canīt
> create a new element of it.


Why couldn't you? Does <element name="{@name}"/> not work?

Furthermore i need to create the other
> attributes for the new element or maybe i can copy them easily(?). Does
> anybody have any solution? PLZ help me im searching for a long time.


<attribute name="sort"><value-of select="local-name()"/></attribute>

Soren
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      01-11-2006
In article <(E-Mail Removed) .com>,
parvus <(E-Mail Removed)> wrote:

><xsl:element name="{@name}"> ...
>
>doesn't work


> Furthermore with "{@name}" i donīt
>get the value but the name of the attribute. I need the value.


It gives you the value of the attribute. So there must be something
wrong with your version of it, or the stylesheet processor you're using.
You need to give us a complete stylesheet that shows the problem
if you want more help.

-- Richard
 
Reply With Quote
 
parvus
Guest
Posts: n/a
 
      01-11-2006
Ok THX Richard Tobin, now I think its really a problem of my stylesheet
processor. Which processor do you use? Im using this M$ IEXMLTLS.

 
Reply With Quote
 
Soren Kuula
Guest
Posts: n/a
 
      01-11-2006
parvus wrote:
> Big THX for these very fast answers, but
>
> <xsl:element name="{@name}"> ...
>
> doesnīt work thats the problem. Furthermore with "{@name}" i donīt
> get the value but the name of the attribute. I need the value. I
> searched on www.w3.org but i didnīt find any solution.


Sure you did not write {name()} ??

Soren
 
Reply With Quote
 
parvus
Guest
Posts: n/a
 
      01-12-2006
So i post my XML and XSLT File maybe youīll find the mistake:
XML:
-------

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="rdm.xslt"?>

<any>
<struct name="identity" type="IDM:RDM/Track:1.0">100</struct>
<struct name="strength" type="IDM:RDM/TrackStrength:1.0">200</struct>
<string name="test"></string>
</any>

XSLT:
--------

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes"/>

<xsl:template match="/">
<any>
<xsl:apply-templates/>
</any>
</xsl:template>

<xsl:template match="any/struct[1]">
<xsl:for-each select="@name">
<xsl:element name="{@name}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:template>
.............

With this XSLT my Browser IE 6.0.2800.1106 replys:
"Um Knoten vom Typ 'ELEMENT' zu erstellen, muss ein gültiger Name
angegeben werden."

That means:
"When you want to create nodes type ELEMENT you should enter a valid
name"

 
Reply With Quote
 
parvus
Guest
Posts: n/a
 
      01-12-2006
Oh dear what a mistake . BIG BIG BIG THX!!! It works. I think it was
a bad Newbie Mistake. Really THX!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt: how to use value from xml data as an attribute value in output html? =?UTF-8?b?5byg6Z+h5q2m?= XML 3 10-23-2006 02:31 PM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments