the reference of the content of XML element

M

mavis

the reference of the content of XML element

In XSD, how can I specify the content of an element refers to the
content of another element in an xml file?

Thanks a lot!
 
J

Joe Kesselman

mavis said:
In XSD, how can I specify the content of an element refers to the
content of another element in an xml file?

Make the value a keyref or idref to that other element? Or make the
value an XPath which can be used to find that element?
 
M

mavis

Thanks a lot ,

Could you instruct how to refer to another element if it is not key or
unique by using xpath?
 
J

Joe Kesselman

mavis said:
Could you instruct how to refer to another element if it is not key or
unique by using xpath?

An XPath is a description of how to find information within a document
-- a simple query operation, if you want to look at it that way.

It's up to the environment to say which document; there's no reason your
system can't use an XPath within a doc to refer to another part of that
doc. XSLT stylesheets sometimes do exactly this, examining themselves to
(for example) do a table lookup. In XSLT, any XPath starting with a call
to the no-arguments version of the document() function is a request to
search the stylesheet document.

Of course, actually following the XPath to the node it refers to will
require running an XPath interpreter, giving it the approrpiate context
information. The TrAX APIs are one semi-standardized way of doing that
in Java; DOM Level 3 also introduces its own XPath API.
 
M

mavis

Thanks. I mean how can we deifne this in the schema file? For example,
in the XSD file, set the default value of an element to be the content
from another element??

Thanks!
 
J

Joe Kesselman

mavis said:
Thanks. I mean how can we deifne this in the schema file? For example,
in the XSD file, set the default value of an element to be the content
from another element??

No can do. This is something the application needs to deal with, not the
schema. Schemas are best thought of as constraining and typechecking
documents; copying a value from one place to another is outside their scope.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,258
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top