Subject: Duplicate Attribute Name
Posted By: Mitali Post Date: 7/24/2008 4:11:50 AM
Hello friends,

In My XSLT file i have to use Idnumber twice as it comes 2 times.
Like
<FileHeader idnumber='{id/@Number1}' idnumber='{id/@number2}'

So wat can I do as i want both numbers with same name?


thanks in advance.

Reply By: samjudson Reply Date: 7/24/2008 4:26:21 AM
That would not generate valid XML and is therefore not allowed. You cannot have two attributes with the same name (and namespace).

/- Sam Judson : Wrox Technical Editor -/
Reply By: mhkay Reply Date: 7/24/2008 9:36:57 AM
You can't have multiple attributes with the same name, that's a basic XML rule. Use child elements instead:

<FileHeader>
  <idnumber>001</idnumber>
  <idnumber>002</idnumber>
</FileHeader>

Alternatively it's sometimes appropriate to use a space-separated list of values

<FileHeader idnumber="001 002"/>



Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply By: Mitali Reply Date: 7/25/2008 1:25:22 AM
OK .thanks.
quote:
Originally posted by mhkay

You can't have multiple attributes with the same name, that's a basic XML rule. Use child elements instead:

<FileHeader>
  <idnumber>001</idnumber>
  <idnumber>002</idnumber>
</FileHeader>

Alternatively it's sometimes appropriate to use a space-separated list of values

<FileHeader idnumber="001 002"/>



Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference



Reply By: Mitali Reply Date: 7/25/2008 1:26:16 AM
OK.Thanks for your reply.
quote:
Originally posted by samjudson

That would not generate valid XML and is therefore not allowed. You cannot have two attributes with the same name (and namespace).

/- Sam Judson : Wrox Technical Editor -/




Go to topic 12253

Return to index page 1