Question about tag and value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mittra@juno.com

    Question about tag and value

    Hello All,

    I am a newbie to XML. I have the following question: how do I express
    something in XML when the subsequent tag structures depends on the
    value of a preceeding tag?

    For example, when TAG2 has a value of 1, then TAG3 exists.

    <TAG1>
    <TAG2>1</TAG2>
    <TAG3>some_valu e</TAG3>
    </TAG1>

    But when TAG2 has a value of 2, then TAG4 exists.

    <TAG1>
    <TAG2>2</TAG2>
    <TAG4>some_valu e2</TAG4>
    </TAG1>

    Can the above two be combined into a single structure for TAG1?

    Thanks for your insight.

  • Philippe Poulard

    #2
    Re: Question about tag and value

    hi,

    mittra@juno.com a écrit :
    >
    if (TAG2 value is 1) then
    <TAG3>some_valu e</TAG3>
    else
    <TAG4>some_valu e2</TAG4>
    >
    Perhaps, XML Schema does it?
    >
    this is exactly the way the Active Schema Language works : you can
    define dynamically the content model that suits your needs, potentially
    with the help of if-then-else statements

    although ASL is experimental, it is implemented and works fine : you can
    use it for your own needs if you don't have to share your own schemas
    with third-party users ; ASL will allow you to express much more complex
    constraints than legacy schema technologies can (DTD, W3C XML Schema,
    RelaxNG, Schematron)

    the implementation :

    the specification :

    some tutorials :


    if you are new to XML, you'll have to understand namespaces in XML and
    learn XPath before (which are widely used in XML technologies)

    some courses :


    ....if you are new to french, you'll have to learn french before :)

    --
    Cordialement,

    ///
    (. .)
    --------ooO--(_)--Ooo--------
    | Philippe Poulard |
    -----------------------------

    Have the RefleX !

    Comment

    Working...