Xsl Generate-id Key Example
Grouping Using the Muenchian Method. Grouping is a common problem in XSLT stylesheets: how do you take a list of elements and arrange them into groups. One of the most common situations in which it occurs is when you are getting XML output from a database. Generate-id Function.; 2 minutes to read; In this article. Returns a string that uniquely identifies the node in the node-set argument that is first in document order. String generate-id(node-set?) Remarks. The unique identifier must consist of ASCII alphanumeric characters and must start with an alphabetic character. Sep 12, 2007 Today’s post comes from a tutorial I’m working on for a customer who still does a lot of XML/XSL stuff. One of the more challenging things to do in XSL1.0 (which is what most browsers support) was getting a distinct list of values from a set of nodes.
The generate-id function returns a string value that uniquely identifies a specified node. If the node-set specified is empty, an empty string is returned. If you omit the node-set parameter, it defaults to the current node.
-->Returns a string that uniquely identifies the node in the node-set argument that is first in document order.
Remarks
The unique identifier must consist of ASCII alphanumeric characters and must start with an alphabetic character. Free diablo 3 game key generator. Thus, the string is syntactically an XML name. There is no guarantee that a generated unique identifier will be distinct from any unique IDs specified in the source document. If the node-set argument is empty, the empty string is returned. If the argument is omitted, it defaults to the context node.
Example
XML File (data.xml)
XSLT File (sample.xsl)
Xsl Generate-id Key Example Free
This is the formatted output:
When you click the left button in Internet Explorer, an alert box displays 'IDAHAGJD'.
When you click the right button in Internet Explorer, an alert box displays 'IDAPAGJD'.
Notice that the ID value is generate at run-time. Therefore, the specific values may vary in different invocation of the transformation.
This is the processor output: Legend of the red dragon key generator for sale.
<html>
<body><button>Gambardella, Matthew</button>
<button>Ralls, Kim</button></body>
Xslt Document Function Examples
Xsl Key Function
</html>
See Also
Reference
- XSLT Tutorial
- XSLT Useful Resources
- Selected Reading
<xsl:key> tag element specifies a named name-value pair assigned to a specific element in an XML document. This key is used with the key() function in XPath expressions to access the assigned elements in an XML document.
Declaration
Following is the syntax declaration of <xsl:key> element.
Attributes
S.No | Name & Description |
---|---|
1 | Name Name of the key to be used. |
2 | Match Patterns used to identify a node that holds this key. |
3 | Use XPath expression to identify the value of the nodes of xml document. |
Elements
Number of Occurrences | Unlimited |
Parent elements | xsl:stylesheet |
Child elements | None |
Demo Example
This example creates a table of <student> element with its attribute rollno and its child <firstname>, <lastname>, <nickname>, and <marks> by iterating over each student. It checks key as firstname to be one of the student's name and then prints the student details.
students.xml
students.xsl