Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2005, 09:42 AM
Registered User
 
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to match elements starting with

hi,

i have a problem as how to match elements that start with a particular string...i have an xml tht generates dynamically and i need to convert it in to a standard format xml...using xslt...

for ex:wherein it may generate elements from child1 to child50 or child5 to child40...anyways...
<parent>
<child1>1st child</child1>
<pet></pet>
<child2>2nd child</child2>
</parent>

i need to convert it into
<parent>
<pet></pet>
<childrens><childnumber>1</childnumber></childrens>
<childrens><childnumber>1</childnumber></childrens>
</parent>

i need to select all the elements starting with child and convert it into childrens..
how about doing it..pleaser help me..as it is a work stopper...
thanks in advance
roopa


 
Old October 20th, 2005, 10:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<child1>1st child</child1>
<pet></pet>
<child2>2nd child</child2>


That's a really bad XML document design - never try to capture an attribute of an object as part of its name. It should be <child sequence="1">1st child</child>. If you have to transform this nonsense into something better, use match="*[starts-with(local-name(), 'child')]"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
template match doesnt match the required node Tomi XSLT 2 March 12th, 2007 06:24 AM
How to Only Match Elements that Equal an XSL Var? tclancy XSLT 1 April 21st, 2006 04:05 PM
Just starting... lozbritt9 C++ Programming 1 March 10th, 2006 12:54 PM
Elements that don't match any templates clareE XSLT 3 December 21st, 2005 06:20 AM
Help!! i need to get a closest match tseng Access VBA 3 February 4th, 2005 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.