How to reference to a part of the XML doc?

Discussion in 'XML' started by panzy, Apr 6, 2004.

  1. panzy

    panzy Guest

    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
     
    panzy, Apr 6, 2004
    #1
    1. Advertising

  2. In article <c4u3ch$8k5$>,
    panzy <> wrote:

    % 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.
    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Apr 7, 2004
    #2
    1. Advertising

  3. panzy

    panzy Guest

    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
    ..
    "Patrick TJ McPhee" <> wrote in message
    news:c4vi1h$5rm$...
    > In article <c4u3ch$8k5$>,
    > panzy <> wrote:
    >
    > % 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.
    > --
    >
    > Patrick TJ McPhee
    > East York Canada
    >
     
    panzy, Apr 7, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Wallace
    Replies:
    0
    Views:
    477
    John Wallace
    Jul 22, 2003
  2. Matt
    Replies:
    3
    Views:
    510
    Tor Iver Wilhelmsen
    Sep 17, 2004
  3. Praveen Chhangani

    Converting a org.jdom DOC to org.w3c DOC

    Praveen Chhangani, Aug 5, 2003, in forum: XML
    Replies:
    2
    Views:
    971
    Johannes Koch
    Aug 7, 2003
  4. News123
    Replies:
    0
    Views:
    297
    News123
    Feb 6, 2010
  5. Replies:
    0
    Views:
    137
Loading...

Share This Page