473,406 Members | 2,390 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,406 software developers and data experts.

picking value of one attribute based on a child elements attribute? XPath?

Hi,

I'm relatively new to xml. I want to have a xml element of the form:

<!ELEMENT CAR (MAKE, COMPANY)>
<!ATTLIST CAR
TYPE PCDATA
PRICE PCADATA>

<!ELEMENT COMPANY (HQ, COMPANY_TYPE)>

Is there a way such that CAR/TYPE has the same value as
CAR/COMPANY/COMPANY_TYPE either using DTD or a schema . For example,
whenever,

CAR/COMPANY/COMPANY_TYPE = "PRICEY"
then,
CAR/TYPE = "PRICEY"

I think something like XPath is needed but am not sure how to go about
getting this. Can I use XPath inside XML elements to point to value of
other elements.

Vinay

Mar 1 '06 #1
2 1285
vj******@gmail.com wrote:
Hi,

I'm relatively new to xml. I want to have a xml element of the form:

<!ELEMENT CAR (MAKE, COMPANY)>
<!ATTLIST CAR
TYPE PCDATA
PRICE PCADATA>
PCDATA is for element character data content. For attributes just use
CDATA. You also need to specify if a value is compulsory (#REQUIRED)
or optional (#IMPLIED), eg

<!ATTLIST CAR TYPE CDATA #REQUIRED PRICE CDATA #IMPLIED>
<!ELEMENT COMPANY (HQ, COMPANY_TYPE)>

Is there a way such that CAR/TYPE has the same value as
CAR/COMPANY/COMPANY_TYPE either using DTD or a schema. For example,
whenever,

CAR/COMPANY/COMPANY_TYPE = "PRICEY"
then,
CAR/TYPE = "PRICEY"
Not in an XML DTD. Something similar is possible in SGML (CONREF).
But why do you want to do this? It's only necessary to give information
once.
I think something like XPath is needed but am not sure how to go about
getting this. Can I use XPath inside XML elements to point to value of
other elements.


No. That's something you do in your processing language (eg XSLT). But
using a Schema language may help.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Mar 1 '06 #2
W3C XML Schema identity constraints can enforce the kind of equality
you require -- see the W3C XML Schema Primer [1] for an introduction.

ht

[1] http://www.w3.org/TR/xmlschema-0/
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Mar 6 '06 #3

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

Similar topics

4
by: Brad | last post by:
Help, I have a really complicated XPATH request I can't wrap my head around I have an XML nodeset like this: <a> <a1 attr="key">Use</a1> <a1 attr="val">Value1</a2> </a> <a> <a1...
4
by: Pat Turner | last post by:
Hi, I have some XML like this: <family> <person name="bob"> <father ref="../../person" /> </person> <person name="charlie"> <child ref="../../person" />
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
12
by: ~~~ .NET Ed ~~~ | last post by:
Hi, I have a standalone XML file (with the appropriate xml document header) that works fine when I load it using XmlDocument. I can have child elements like this without problems: ...
1
by: soupaman | last post by:
Im trying to output some filtered xml using the xmlTextReader I know the code and commenting needs cleaned up and eventually plan to add the values to a dataset. currently what this is doing is...
4
by: ina | last post by:
Hello all, I am newbie in xml and have a problem with this parse. I have this xml.file <Style> <Strategy>
3
by: patrizio.trinchini | last post by:
Hi, how can remove sibling elements based on the value of an attribute ? For instance, gven the XML document: <root> <parentElment> <testElement name="A"> <removableElement/>
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
2
by: pstachy | last post by:
Hi again! I have another issue. I would like the attribute of the tag <invoice> to be unique. Made the following schema but unfortunately it doesn't validate. Could someone please indicate what is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.