[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

I've modified my parser to copy attributes. Am I wrong?

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
xsl copy attributes
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.