XML Check Validation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

XML Check Validation

Nemea Lion
Hi

Would someone please help me on this?

If I have an xml like this

<xml>
    <firstNode>
        ....
    </firstNode>
<!--here can be secNode-->
</xml>

In thet structure, instead of the comment you can have:

nothing: (firstNode becomes self closed)

a selfClosed: secNode with some attribs

<secNode myAttrib="myValue"/>

a secNode with one of the following nodes

<thirdNode>.....</thirdNode>
<fourthNode>...</fourthNode>
<fifthNode>...</fifhNode>


I try a rule like this..
...(some other rules)...
ROptional(RNode("secNode",[],
    ROptional(
        RChoice(
            RData(),
            RNode("thirdNode",[],ROptional(RData())),
            RNode("fourthNode",[],ROptional(RData())),
            RNode("fifthNode",[],ROptional(RData())),
        )
    )
)

However I get "secNode is missing element "thirdNode".

Obviously I'm not constructing the rule correctly, but there is a lack of documention.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: XML Check Validation

Nemea Lion
Dammm, the mail got sent before i finnished it.

2011/6/9 Nemea Lion <[hidden email]>
Hi

Would someone please help me on this?

If I have an xml like this

<xml>
    <firstNode>
        ....
    </firstNode>
<!--here can be secNode-->
</xml>

In thet structure, instead of the comment you can have:


nothing: (secNode may not appear)

a selfClosed: secNode with some attribs
<secNode myAttrib="myValue"/>

a secNode with one of the following nodes

<thirdNode>.....</thirdNode>
<fourthNode>...</fourthNode>
<fifthNode>...</fifhNode>


I try a rule like this..
...(some other rules)...
ROptional(RNode("secNode",[],
    ROptional(
        RChoice(
            RData(), // <-- I suppouse that this is for the self closed case, since for a self closed node you use ROptional(RData())
            RNode("thirdNode",[],ROptional(RData())),
            RNode("fourthNode",[],ROptional(RData())),
            RNode("fifthNode",[],ROptional(RData())),
        )
    )
)

However I get "secNode is missing element "thirdNode" when a selfClosed secNode appears

eg:

<xml><firstNode>data</firstNode><secNode/></xml>

Obviously I'm not constructing the rule correctly, but there is a lack of documention.
For a node without childs that can or cannot be self closes I have previously used ROptional(RData()),
but I don't know how to interact with self closed or with child nodes....
What would the correct rule be for this case?

Thanks!

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: XML Check Validation

Nemea Lion
Mmmm, have you noted how sometimes you only need to ask for help
to get the answer right in your head. I have managed to correct this,
I was using ROptional inadequately.


2011/6/9 Nemea Lion <[hidden email]>
Dammm, the mail got sent before i finnished it.


2011/6/9 Nemea Lion <[hidden email]>
Hi

Would someone please help me on this?

If I have an xml like this

<xml>
    <firstNode>
        ....
    </firstNode>
<!--here can be secNode-->
</xml>

In thet structure, instead of the comment you can have:


nothing: (secNode may not appear)


a selfClosed: secNode with some attribs
<secNode myAttrib="myValue"/>

a secNode with one of the following nodes

<thirdNode>.....</thirdNode>
<fourthNode>...</fourthNode>
<fifthNode>...</fifhNode>


I try a rule like this..
...(some other rules)...
ROptional(RNode("secNode",[],
    ROptional(
        RChoice(
            RData(), // <-- I suppouse that this is for the self closed case, since for a self closed node you use ROptional(RData())

            RNode("thirdNode",[],ROptional(RData())),
            RNode("fourthNode",[],ROptional(RData())),
            RNode("fifthNode",[],ROptional(RData())),
        )
    )
)

However I get "secNode is missing element "thirdNode" when a selfClosed secNode appears

eg:

<xml><firstNode>data</firstNode><secNode/></xml>


Obviously I'm not constructing the rule correctly, but there is a lack of documention.
For a node without childs that can or cannot be self closes I have previously used ROptional(RData()),
but I don't know how to interact with self closed or with child nodes....
What would the correct rule be for this case?

Thanks!


--
haXe - an open source web programming language
http://haxe.org