spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How to require one, or the other, or both child elements


The easiest change to the XSD would be make both optional via minOccurs="0":

<xs:element
name="scheduled_times">
    <xs:complexType>
        <xs:sequence> 
            <xs:element ref="arrival_time" 
minOccurs="0"/>
            <xs:element ref="departure_time"
minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>            
</xs:element>

Note, though, that this will also allow neither to be present. The either, both, but not neither, case is a bit tricky because of the Unique Particle Attribution constraint.

Wrong - violates Unique Particle Attribution

Trying the straightforward approach of listing the desired possibilities via xs:choice:

  <xs:element
name="scheduled_times">
    <xs:complexType>
      <xs:choice>
        <xs:sequence>
          <xs:element ref="arrival_time"/>
        </xs:sequence>
        <xs:sequence>
          <xs:element ref="departure_time"/>
        </xs:sequence>
        <xs:sequence>
          <xs:element ref="arrival_time"/>
          <xs:element ref="departure_time"/>
        </xs:sequence>
      </xs:choice>
    </xs:complexType>            
  </xs:element>

will run afoul of the Unique Particle Attribution constraint:

cos-nonambig: arrival_time and arrival_time (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.

Correct - does not violate Unique Particle Attribution

To resolve the ambiguity, re-work the choice so that the possibilities are unambiguous:

  <xs:element
name="scheduled_times">
    <xs:complexType>
      <xs:choice>
        <xs:sequence>
          <xs:element ref="arrival_time"/>
          <xs:element ref="departure_time"
minOccurs="0"/>
        </xs:sequence>
        <xs:element ref="departure_time"/>
      </xs:choice>
    </xs:complexType>            
  </xs:element>

Categories : Xml

Related to : How to require one, or the other, or both child elements
XSL Transform for Multiple Child Elements
Instead of simply using value-of use apply-templates: <xsl:template match="cl:key-term-entry"> <tr> <td><xsl:apply-templates select="cl:key-term"/></td> <td><xsl:apply-templates select="cl:key-term-def"/></td> </tr> </xsl:template> Then of course you need to add templates for the other elements you want to trans

Categories : Xml
Ruby: Using require produces "in `require': cannot load such file "
You have an unwanted dot in unit., replace your require with: require File.expand_path("../../test_helper", __FILE__) # Or maybe require File.expand_path("../test_helper", __FILE__)

Categories : Ruby On Rails
How to fix onmouseout called when hovering over child elements?
Instead of adding the words using JavaScript, you could put them in the HTML, and hide/display them using CSS: .song div { display: none; } .song:hover div { display: block; } Fiddle

Categories : Javascript
Jquery sort child elements in DIV tage
sort requires you return an integer which controls the sorting. For example in your case you would have something like if(a.id == b.id) return 0; if(a.id < b.id) return -1; else return 1; // a.id > b.id Also you have some problems with the jQuery code that is handling sorting the elements. First the call $('#executiongraph > span') already returns an Array of jquery objects so toArra

Categories : Jquery
Knockout 3.2: can components / custom elements contain child content?
It's impossible in 3.2, however it would be possible in next version, see this commit and this test. For now to you have to pass parameters to component via params property Define your component to expect content parameter: ko.components.register('modal-dialog', { viewModel: function(params) { this.content = ko.observable(params && params.content || ''); }, template:

Categories : Knockout Js
Recently Add
get array result with wsdl and complexType
Same xml element in different places
How to post XML data to plone view and return xml data to sender?
Should a REST service expose a XSD for XML responses?
Querying a log file with multiple XML objects
How to set sorter of a List in Controller in SAPUI5?
XSLT Creating repetitive elements from Complex XML with Field and Metadata ids
and in a xml element
XML Nodes to be inserted with XSLT into a second Stylesheet
wso2 esb smooks un/edifact 96a EDI to XML
A complex type without an element in XSD
Convert rows of spreadsheet to separate XML files
XSLT mapping with metadata and field tags with multiple repetitive elements
Scala - Getting the error scala.xml.NodeSeq
XSLT - get value of all nodes with the same name
XSLT string join error
How do I parse XML web service in Swift?
Creating a complexType from multiple complexTypes
XSL repeating the same value but counting the correct number of different values
trying to export a complex xml from excel 2013
vb.net XML For loop
Chrome 39 XML/XSLT Renders Blank Page
How to make a drop down menu using xslt and xml?
xslt tokenize() and "Not a node item" error
Perl dies on big XML file, using STDIN
How to use custom sorter in XML views
distinct-values, contains function failed
Xslt code for fetching name value basing on the id value given in input
DonĀ“t preload images in XML (google maps API v3)
rename and send all child nodes based on value of element in child node in xslt
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.