How to reference to a part of the XML doc?

panzy

Usenet Archive
Joined
Apr 6, 2004
Messages
2
Reaction score
0
Hi,

I have this structure:

<a>
<repeated_part>
<just_the_same_thing_and_more/>
</repeated_part>
</a>
<b>
<repeated_part>
<just_the_same_thing_and_more/>
</repeated_part>
</b>

Is it possible to refactor this at text doc level to something like this:

<repeated_part>
<just_the_same_thing_and_more/>
</repeated_part>
<a>
<reference to the repeated_part>
</a>
<b>
<reference to the repeated_part>
</b>

Pls note: I want parse this DOC and work with the DOM.
After parsing and using the DOM the tree should be very similar to the first case:
The node <A> should have a child node <repeated part>

Is there any standard XML solution?

thx for answers
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
% I have this structure:
%
% <a>
% <repeated_part>
% <just_the_same_thing_and_more/>
% </repeated_part>
% </a>
% <b>
% <repeated_part>
% <just_the_same_thing_and_more/>
% </repeated_part>
% </b>
%
% Is it possible to refactor this at text doc level to something like this:
%
% <repeated_part>
% <just_the_same_thing_and_more/>
% </repeated_part>
% <a>
% <reference to the repeated_part>
% </a>
% <b>
% <reference to the repeated_part>
% </b>

Note that neither of these is well-formed. Anyway, doing it like this will result in a different DOM tree. You can put the repeated part in an entity definition, though, something like:

<!DOCTYPE missing-outer-element [
<!ENTITY repeated_part '<just_the_same_thing_and_more/>'> ]>

<missing-outer-element>
<a>
&repeated_part;
</a>
<b>
&repeated_part;
</b>
</missing-outer-element>

This will result in identical DOM trees provided you make the spacing consistent.
 

panzy

Usenet Archive
Joined
Apr 6, 2004
Messages
2
Reaction score
0
Hi Patrick,

Thx for your fast answer.

I'd like to use elements, attributes as the repeated part. With other words my repeated part is a chunk of XML text. Can I do this with Entities what you recommend?

I'd like to avoid DTD. I use an external xsd schema. Is any other way to complete my task?

thx for answers
..
 

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

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top