English 中文(简体)
Xslt - Enforcing @attribute uniqueness
原标题:

I rarely work with xslt s so I m not the greatest at it, but, I was wondering how to go about solving this problem:

<Element>
   <childElement type="type1">Bob</childElement>
   <childElement type="type1">Smith</childElement>
   <childElement type="type2">Bob</childElement>
</Element>"

I want to enforce @type uniqueness, where I would just grab one of the ChildElements if they have the same @type. Different @types can have the same value (in this example, the 2 Bobs would be okay). Any help on how to solve this in xslt?

最佳回答

Here is an XPath to grab only the unique @type values...

//childElement[not(@type=preceding::childElement/@type)]

...result from your example is...

Location: 3:5
Description: /Element[1]/childElement[1] - Bob
Location: 5:5
Description: /Element[1]/childElement[3] - Bob
问题回答

暂无回答




相关问题
When test hanging in an infinite loop

I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

quick xslt for-each question

Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

XSLT Transform XML with Namespaces

I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

XSLT output to HTML

In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

Mangling IDs and References to IDs in XML

I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签