Subject: RE: Matching elements with a name specified by an attribute value From: "SCOTT, Darren, FM" <Darren.Scott@xxxxxxxx> Date: Mon, 23 Oct 2000 09:27:46 +0100 |
Thanks Mike - I didn't think about using the name() function!!! You say that what I'm trying to do is bad document design. Maybe I should have used different names in my example to give a better idea of what I'm trying to do. If I redo the example again, does it make more sense this time? Essentially, the names of the data elements do identify types, and are all different... <layout layout-id="block1"> <layout_item data_element="reference"/> <layout_item data_element="trade_date"/> <layout_item data_element="ccy"/> <layout_item data_element="amount"/> </layout> <trade layout-ref="block1"> <reference>12345</reference> <trade_date>23-Oct-2000</trade_date> <ccy>GBP</ccy> <amount>1,500.00</amount> </trade> The reason I'm structuring my XML this way is so that I can separate page layout from actual page data contents instead of embedding layout in the XSLT. The first section of the document is a static layout template (using <layout> elements), and the second section is the corresponding content generated dynamically from some business object. By doing this, I can use a single XSLT for all pages of a similar type (to maintain a consistent look and feel), with the different layouts being specified by different blocks of layout XML. Does this sound a good way of achieving this level of flexibility? -----Original Message----- From: Kay Michael [mailto:Michael.Kay@xxxxxxx] Sent: 20 October 2000 16:11 To: 'xsl-list@xxxxxxxxxxxxxxxx' Subject: RE: Matching elements with a name specified by an attribute value > Is it possible to match on elements where the names of the > elements to look > for are specified as the attribute values of other elements > ie. the element > name to match is specified at processing time? > > Consider the example source XML... > > <layout> > <layout_item data_element="item1"/> > <layout_item data_element="item2"/> > <layout_item data_element="item3"/> > </layout> > > <item1>I am item 1</item1> > <item2>I am item 2</item2> > <item3>I am item 3</item3> > You can do //*[name()=@data-element] But this is not a nice document design. Element tags are intended for identifying types, not instances. To identify instances, you should use an id attribute: <item id="item1"> Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list ******************************************************************** This e-mail is intended only for the addressee named above. As this e-mail may contain confidential or privileged information, if you are not the named addressee, you are not authorised to retain, read, copy or disseminate this message or any part of it. ******************************************************************** XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Matching elements with a name s, Kay Michael | Thread | Re: Matching elements with a name s, Benoit Cerrina |
Re: mathml xsl stylesheets?, STENZEL | Date | RE: Quoting quotes?, Kay Michael |
Month |