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

RE: Is there a way in xsl to point to a node if only a

Subject: RE: Is there a way in xsl to point to a node if only a part of its name is known?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 22 Nov 2001 10:24:57 -0000
xsl sanitise
> I'm trying to build a 'generic' xsl which will be able to
> style a certain
> type of xml I get back when querying a database. The xml structure/
> hierarchy always stays the same but unfortunately the text
> node 'naming'
> partly changes. A text node name consists of
> 'tablename.fieldname' where
> tablename is the changing- and fieldname the fixed part.

I'd say that's a lousy bit of XML design, but as stylesheet writers, we
sometimes have to cope with lousy XML.

Your only option is to use expressions (or patterns) like:

  *[substring-before(name(), '.')='tableName1']

Alternatively (a generally useful tip when processing badly-designed XML),
do a two-phase transformation, the first phase being there purely to
sanitise the XML into something more reasonable. In this case (as in many
other cases) the first phase could be a simple SAX filter, replacing
<tablename1.fieldname1> by <field table="tablename1"
fieldname="fieldname1">.

Mike Kay

>
> Is there a way in xsl to point to a node if only a part of its name is
> known?
>
> Thanks,
> -Michael
>
>
> Sample xml 1:
> <node1>
>   <node2>
>     <node3>
>       <tableName1.field1>content ...</tableName1.field1>
>       <tableName1.field2>content ...</tableName1.field2>
>       <tableName1.field3>content ...</tableName1.field3>
>     </node3>
>   </node2>
> </node1>
>
> Sample xml 2:
> <node1>
>   <node2>
>     <node3>
>       <tableName2.field1>content ...</tableName2.field1>
>       <tableName2.field2>content ...</tableName2.field2>
>     </node3>
>   </node2>
> </node1>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 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.