473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Get root attribute values question 2

If I have

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b>
<root>

What expression will fetch the value of AAA when processing
elements c ?

Is there an expression that works for both elements c and d ?
Thanks.
Jul 20 '05 #1
8 1501

"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
If I have

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b>
<root>

What expression will fetch the value of AAA when processing
elements c ?

Is there an expression that works for both elements c and d ?


Not in your case -- you must first have a well-formed xml document.

Jul 20 '05 #2
This xml should be better ...

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b/>
<root>

Is there a way to reference some_attr when processing both c and d
where the expression is the same for both?
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message news:<c5*************@ID-152440.news.uni-berlin.de>...
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
If I have

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b>
<root>

What expression will fetch the value of AAA when processing
elements c ?

Is there an expression that works for both elements c and d ?


Not in your case -- you must first have a well-formed xml document.

Jul 20 '05 #3
Sorry, it's still not a well-formed xml document.
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
This xml should be better ...

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b/>
<root>

Is there a way to reference some_attr when processing both c and d
where the expression is the same for both?
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message

news:<c5*************@ID-152440.news.uni-berlin.de>...
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
If I have

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b>
<root>

What expression will fetch the value of AAA when processing
elements c ?

Is there an expression that works for both elements c and d ?


Not in your case -- you must first have a well-formed xml document.

Jul 20 '05 #4
hah. hah. hah ...

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c></b>
</root>
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message news:<c5*************@ID-152440.news.uni-berlin.de>...
Sorry, it's still not a well-formed xml document.
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
This xml should be better ...

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b/>
<root>

Is there a way to reference some_attr when processing both c and d
where the expression is the same for both?
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message

news:<c5*************@ID-152440.news.uni-berlin.de>...
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
> If I have
>
> <root>
> <a some_attr="AAA"/>
> <b><c/></b>
> <b><c/></b>
> <b><c/></b>
> <b><c><d/></c><b>
> <root>
>
> What expression will fetch the value of AAA when processing
> elements c ?
>
> Is there an expression that works for both elements c and d ?

Not in your case -- you must first have a well-formed xml document.

Jul 20 '05 #5
Assuming that using this well-formed XML:

<root>
<a some_attr="AAA"/>
<b>
<c/>
</b>
<b>
<c/>
</b>
<b>
<c/>
</b>
<b>
<c>
<d/>
</c>
</b>
</root>

this stylesheet/template seems to find the attribute value
and output it to the screen when I look for the "d" element...

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="//d">
<xsl:for-each select="preceding::node()">
<h4><xsl:value-of select="attribute::*"/></h4>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>
Jul 20 '05 #6
Use:

preceding::a[1]/@some_attr
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
hah. hah. hah ...

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c></b>
</root>
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message

news:<c5*************@ID-152440.news.uni-berlin.de>...
Sorry, it's still not a well-formed xml document.
"GIMME" <gi*******************@yahoo.com> wrote in message
news:3f**************************@posting.google.c om...
This xml should be better ...

<root>
<a some_attr="AAA"/>
<b><c/></b>
<b><c/></b>
<b><c/></b>
<b><c><d/></c><b/>
<root>

Is there a way to reference some_attr when processing both c and d
where the expression is the same for both?
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message

news:<c5*************@ID-152440.news.uni-berlin.de>...
> "GIMME" <gi*******************@yahoo.com> wrote in message
> news:3f**************************@posting.google.c om...
> > If I have
> >
> > <root>
> > <a some_attr="AAA"/>
> > <b><c/></b>
> > <b><c/></b>
> > <b><c/></b>
> > <b><c><d/></c><b>
> > <root>
> >
> > What expression will fetch the value of AAA when processing
> > elements c ?
> >
> > Is there an expression that works for both elements c and d ?
>
> Not in your case -- you must first have a well-formed xml document.

Jul 20 '05 #7
"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message news:<c5*************@ID-152440.news.uni-berlin.de>...
Use:

preceding::a[1]/@some_attr
Cheers,

Dimitre Novatchev [XML MVP],

One line, sweet!
Jul 20 '05 #8
asdfasd

Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Russell O'Connor | last post by:
The following XML and Schema doesn't validate in Visual Studio .NET 2003. Is there some mistake I'm making, or is VS.NET in error. The error is r:\test2.xml(3): The key sequence 'foo' in Keyref...
3
by: GIMME | last post by:
Hi, <root some_attr="edit"> <a/><a/> <root> How do I access the value of some_attr when processing <a/> ? Sort of like if I had <root>
1
by: jm | last post by:
I get "data at the root level is invalid." I have changed security for the IUSR_xx to be in the adminstrators (tried anonymous access); changed all the file security I could; tried virtual...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
1
by: jm | last post by:
I get "data at the root level is invalid." I have changed security for the IUSR_xx to be in the adminstrators (tried anonymous access); changed all the file security I could; tried virtual...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
1
by: Tedros.G | last post by:
Hi I have an attribute the appears in both the root node and child node for example, below the attribute VERSION appears in the rood node (PRODMSG ) and a child node (OPERATION ) ================...
4
by: johnsonkt | last post by:
hi all , when m trying to validate my xml using xsd file it gives me the following error "Data at the root level is invalid. Line 1, position 1" i tried to open the XML file using IE and there...
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.