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

Removing if no data - iterating through every child (

Subject: Removing if no data - iterating through every child (sorry the codes a bit long)
From: "Kevinjohn Gallagher" <web_design_guru@xxxxxxxxxxx>
Date: Fri, 03 Sep 2004 15:21:14 +0100
iterating every node
Initially, sorry for the code seeming long. But it's a bit of a follow up to yesterdays questions (which I solved thanks to y'alls help).



Ok, so I have an XML file, where I can have any number of nodes, which can have any number of Children (and they can have children and so on).

Basically, I want to strip a node if it or it's children has no data, or has no attributes with data anywhere in it's descendants.

I sort of get the logic, but fail miserably to even consider how to fix it so that the last example works (Checkbox 6) - ie. Stripping a tree half way down.

ANY help would be great.

Thanks ALot

Bryan.

P.S. the number of children in the example is not overkill, there will usually be at least 4 - sorry.


ORIGINAL :


		<topNode>
			<Checkbox1>
				<really>
					<long>
						<really>
							<really>
								<long Attribute="0"/>
							</really>
						</really>
					</long>
				</really>
			</Checkbox1>
			<Checkbox2>
				<really>
					<long>
						<really>
							<really>
								<long> data </long>
							</really>
						</really>
					</long>
				</really>
			</Checkbox2>
			<Checkbox3>
				<really>
					<long>
						<really>
							<really>
								<long />
							</really>
						</really>
					</long>
				</really>
			</Checkbox3>
			<Checkbox4>
				<really>
					<long>
						<really>
							<really>
								<long Attribute=""/>
							</really>
						</really>
					</long>
				</really>
			</Checkbox4>
			<Checkbox5>
				<really>
					<long>
						<really>
							<really>
								<long Attribute="0" attribute=""> data </long>
							</really>
						</really>
					</long>
				</really>
			</Checkbox5>
			<Checkbox6>
				<really>
					<long Attribute="data">
						<really>
							<really>
								<long/>
							</really>
						</really>
					</long>
				</really>
			</Checkbox6>
		</topNode>



Output :

		<topNode>
			<Checkbox1>
				<really>
					<long>
						<really>
							<really>
								<long Attribute="0"/>
							</really>
						</really>
					</long>
				</really>
			</Checkbox1>
			<Checkbox2>
				<really>
					<long>
						<really>
							<really>
								<long> data </long>
							</really>
						</really>
					</long>
				</really>
			</Checkbox2>
			<Checkbox5>
				<really>
					<long>
						<really>
							<really>
								<long Attribute="0"> data </long>
							</really>
						</really>
					</long>
				</really>
			</Checkbox5>
			<Checkbox6>
				<really>
					<long Attribute="data" />
				</really>
			</Checkbox6>
		</topNode>

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.