CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011
    Posts
    1

    DTD - parameter entity

    I am having trouble trying to implement parameter entities so that i can repeat text multiple times within the DTD.

    example XML code:
    <accounts>
    <luke>
    <shipping_address>
    <address></address>
    <street></street>
    <city></city>
    <postcode></postcode>
    </shipping_address>
    </luke>

    <angie>
    <billing_address>
    <address></address>
    <street></street>
    <city></city>
    <postcode></postcode>
    </billing_address>
    </angie>
    </accounts>

    The address, street, city, postcode elements both have the same information. How would i reuse these sets of elements multiple times within a DTD document using parameter entity ? i know the key syntax is the % sign, but i can't seem to understand how to code it properly.

  2. #2
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: DTD - parameter entity

    Been a very long time since I've done any DTD, however I'd say your example XML looks wrong to me.
    Is that taken from a real example/requirement or is it just something you put together to try and solve your problem?

    Your XML is going to have problems with the "name" nodes ("luke" and "angie") because it will make you unable to group up content, and I think it might be where your issues also spring from.

    If the XML is something you control; I would advice you to get it rewritten into something more XML-ish like for example:
    Code:
    <accounts>
    <account>
    <owner>luke</owner>
    <shipping_address>
    <address></address>
    <street></street>
    <city></city>
    <postcode></postcode>
    </shipping_address>
    </account>
    
    <account>
    <owner>angie</owner>
    <billing_address>
    <address></address>
    <street></street>
    <city></city>
    <postcode></postcode>
    </billing_address>
    </account>
    </accounts>
    This should enable you to avoid having to repeat your billing_address element, as the entire account element would be the same in a sequence, whereas in your own example, a "luke" tag would not be the same as an "angie" tag.

    I hope this helps, but if not - ignore what I said

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured