XML Schema Checking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sengfoo
    New Member
    • Sep 2008
    • 2

    XML Schema Checking

    Hi all,

    I need you all help me to solve my problem here. The problem im facing now is I have 2 tag to fill in which is

    <Specialization ></Specialization>
    <JobRole></JobRole>

    JobRole's data are inserted base on the value insert in Specialization. For example :

    Specialization : IT/Computer Science
    Job Role : Programmer, Network Administrator, Developer, etc
    Specialization : Secretary
    Job Role : Secretary

    Job Role "Secretary" can only be fill in if only specializaton "Secretary" are inserted. How can i do this in XML schema?

    Your help is needed! Thanks
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

    Is your schema XSD or DTD?

    /MK

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      XSD when I understand it right.

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        So in other words, you can have
        1.
        <Specialization ></Specialization>
        <JobRole></JobRole>

        2. <Specialization >Secretary</Specialization>
        <JobRole></JobRole>

        3. <Specialization >Secretary</Specialization>
        <JobRole>Secret ary</JobRole>

        but this is not allowed?
        4. <Specialization ></Specialization>
        <JobRole>Secret ary</JobRole>

        What you're trying to do is called cooccurrence constraints. You could validate it if you were using extensions, such as schematron http://en.wikipedia.org/wiki/Schematron. The functionality to check what you're doing is not within xml schema, unless you're using key/index constraints, which it doesn't look like you are from your IT example.

        Comment

        • sengfoo
          New Member
          • Sep 2008
          • 2

          #5
          Hi,

          My schema is XSD format.

          And here is my scenario

          Correct:
          <Specialization >IT/Computer Science</Specialization>
          <JobRole>Progra mmer</JobRole>

          Wrong:
          <Specialization >IT/Computer Science</Specialization>
          <JobRole>Secret ary</JobRole>

          where the specialization and job role is a mandatory field

          Thanks for the help!

          Comment

          Working...