Subject: I've modified my parser to copy attributes. Am I wrong? From: Dan Morrison <dman@xxxxxxxx> Date: Wed, 12 Apr 2000 23:26:49 +1200 |
Hey there. Due to a desire for simplicity and a dislike for the ugliness of xsl:attribute workarounds, I've changed the Parser I'm using (XML::XSLT) to allow formulations like: <xsl:template match="TextField" name="TextField"> <input type="Text"> <xsl:copy-of select="@" /> </input> </xsl:template> and <xsl:template match="Button" name="Button"> <input type="Button"> <xsl:for-each select="@"> <xsl:copy-of select="." /> </xsl:for-each> </input> </xsl:template> (XML below if you can't guess what I'm doing ;-) ) I note that an attribute isn't /really/ a first class element, and that the existing structure of XML::DOM doesn't encourage this sort of manipulation, but... is this approach spec-evil or what? I see nothing in the spec that forbids it I've seen several threads asking how to achieve this result, and to my mind, this is the obvious way of doing it. I know it can be done with half a page of xsl:attribute stuff, but whitespace keeps getting in the way if I format it, and my code looks like crap if I don't. Opinions all? .dan. -------------------------------------------------- XML: ---- <Button id="a_button" title="A Button Title" value="value for a button" /> <TextField id="a_TextField" title="A TextField Title" value="value for a TextField" /> | V XHTML: ------ <input type="Button" id="a_button" title="A Button Title" value="value for a button" /> <input type="Text" id="a_TextField" title="A TextField Title" value="value for a TextField" /> -- :=====================:====================: : Dan Morrison : The Web Limited : : http://here.is/dan : http://web.co.nz : : dman@xxxxxxxx : danm@xxxxxxxxx : : 04 384 1472 : 04 495 8250 : : 025 207 1140 : : :.....................:....................: : If ignorance is bliss, why aren't more people happy? :.........................................: XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Rant : "Microsoft is compliant , Medina, Edward | Thread | Re: I've modified my parser to copy, Nikolai Grigoriev |
RE: Inserting attr value in textbox, Medina, Edward | Date | RE: Rant : "Microsoft is compliant , Steven Maring |
Month |