[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: <xsl:attribute issue
Vaduvoiu Tiberiu wrote:
Hi, I am trying to create an attribute for one of my xml files that has a typoical format like: <root> <level1> <name>Name1</name> other tags </level1> <level1> <name>Name2</name> other tags </level1> </root> I wonder what you mean with "display" as XSLT is a transformation language and cannot display anything. From what you read above I got the faint impression that you think you can build an element during transformation (level1/name) and then transform that same element again and request the value of that attribute. Also, you seem to think that you can have any multitude of attributes with the same name on an element (you use xsl:for-each) which is not possible because it is not XML. You create an attribute like this: <xsl:attribute name="bla">value</xsl:attribute> but it must be a direct child of an element, like this: <lre-element> <xsl:attribute name="bla">value</xsl:attribute> </lre-element> if the value is literate, you don't need to use xsl:attribute <lre-element bla="value" /> if the value can be expressed with an xpath expression (as opposed to, say, apply-templates or another for-each), you can use an AVT: <lre-element bla="{path/to/value}" /> Because it seems likely that you have not yet understood the XSLT processing model, or the basic ideas behind it, consider reading a tutorial. There are plenty on the web and I can recommend the books of Jeni Tenison fo starters and Michael Kay's for reference. Good luck coding -- Abel Braaksma PS: your original inquiry seems to be about enhancing existing XML with a couple attributes. Look up the modified copy template which will look something like the following in your case:
<xsl:template match="name"> <xsl:copy> <xsl:attribute name="test">4</xsl:attribute> <xsl:apply-templates select="node() | @*" / </xsl:copy> </xsl:template>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|