I have below complextype
<xsd:complexType name="cidType">
<xsd:choice>
<xsd:sequence>
<xsd:element name="a" type="Type_A"></xsd:element>
<xsd:element name="b" type="Type_B"></xsd:element>
</xsd:sequence>
<xsd:element name="b" type="Type_B"></xsd:element>
</xsd:choice>
</xsd:complexType>
When trying to generate JAXB classes for this schema it's wrong, because, as you see, is repeated reference to the element b the JAXB error gives me is:
/*
* You are getting this "catch-all" property because of the following reason:
* The field name "b" is used by two different parts of a schema.
*/
Since it is an industry standard schema I don't have the liberty to change anything. What is the possible solution?
If i go the customization route, i don't know how to, if possible please point me to a good resource/example. I have already tried my luck with google
I do have an external binding declaration to incorporate data type for some of the elements, but I am not sure how I can use the binding customization to solve my current problem
Related
Can we do the following? If not, can you guide me to choose the attribute group in xsd.
<xsd:complexType name="getGroupType">
<xsd:choice minOccurs="1" maxOccurs="1">
<xsd:attributeGroup ref="groupA"/>
<xsd:attributeGroup ref="groupB"/>
</xsd:choice>
</xsd:complexType>
xsd:choice is called a model group and can only be used with elements, not with attributes. However, it may be possible to emulate a choice on an attribute group using subtypes (two types extending a base one).
I have the following definitions in the XML Schema:
<xsd:complexType name="ExpressionType" abstract="true"/>
<xsd:complexType name="PropertyNameType">
<xsd:complexContent mixed="true">
<xsd:extension base="ogc:ExpressionType"/>
</xsd:complexContent>
</xsd:complexType>
What does the PropertyNameType actually allow as content? Just textual content or is there more to it?
PropertyNameType is a complex type with complex content and mixed="true", extending another empty abstract complex type. That's all. My question is, which content it may have.
It may clearly have textual content (because of mixed="true"). But is something else allowed? Or is there some extension method which would put more stuff in, something with substitution groups perhaps?
To answer your question: No, only textual content is allowed.
So if the element test is defined as:
<xs:element name="test" type="PropertyNameType" />
Then the only valid content is:
<test>Hello World!</test>
No attributes, no child elements.
I am using JAXB to generate domain objects from an XSD of our own devising. In the relevant fragment of the XSD, given below, I have a nested preProcessing element within the parent Job element. This gets resolved into a PreProcessing inner class within the parent Job class, as would be expected.
<xsd:complexType name="Job">
<xsd:element name="preProcessing" nillable="false">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="mask" type="MaskTypeEnum" />
<xsd:element name="userDefinedMaskFile" type="xsd:string" />
<xsd:element name="experimentalDesign" type="xsd:boolean" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
Accessing the inner class is done via a generated pair of get & set methods in the parent Job class, again as would be expected:
public Job.PreProcessing getPreProcessing() {
return preProcessing;
}
public void setPreProcessing(Job.PreProcessing value) {
this.preProcessing = value;
}
I'd like to be able to ensure that, in the Java code, there is always an instance of the PreProcessing class for an instance of Job. To this end, I would like to be able to customise the JAXB generation to either,
1) instantiate a PreProcessing instance in the Job class constructor
2) lazily instantiate a PreProcessing instance when the getter method is called (as happens for lists, which is nice)
The setter method would be redundant (and indeed, should not be called, since the PreProcessing instance is intended to be final).
I've Googled for JAXB + phrases such as lazy instantiation, default value, nested element and drawn a blank thus far. It seems that some class customisations can be carried out using custom XMLAdapters but my scenario isn't really related to the marshalling/unmarshalling, it relates to the manipulation of the domain objects in my Java application.
SDL Tridion uses XML schema definitions to define content stored in Tridion components. XSD can use restrictions/facets or indicators to restrict what's valid for XML nodes.
Chris Summers found some of these accidentally in training, specifically that we can set minOccurs and maxOccurs indicators in SDL Tridion 2011 as in:
<xsd:element name="someField" minOccurs="2" maxOccurs="5" type="xsd:normalizedString">
Andrey Marchuk mentions additional options in the same post:
Indicators
MaxValue
MinValue
Restrictions
FractionDigits
MaxLength
MinLength
Pattern
TotalDigits
Btw, are these XSD-specific?
IsMaxValueExclusive
IsMinValueExclusive
How would I get the *restrictions into the following sample Tridion schema (source)?*
<xsd:schema xmlns="http://createandbreak.net/schema/example" xmlns:tcmi="http://www.tridion.com/ContentManager/5.0/Instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://createandbreak.net/schema/example">
<xsd:import namespace="http://www.tridion.com/ContentManager/5.0/Instance"></xsd:import>
<xsd:annotation>
<xsd:appinfo>
<tcm:Labels xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
<tcm:Label ElementName="someField" Metadata="false">someField</tcm:Label>
</tcm:Labels>
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="Content">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="someField" minOccurs="2" maxOccurs="5" type="xsd:normalizedString">
<xsd:annotation>
<xsd:appinfo>
<tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
To take an example from W3Schools, this would be a non-Tridion XSD restricting a field to 5 digits using a regular expression:
<xs:element name="prodid">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9][0-9][0-9][0-9][0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
I tried changing the xs namespace to xsd but I'm not sure where XSD restrictions would go in the (Tridion) schema.
I believe the XS and XSD is somewhat irrelevant here. Both are actually namespace prefixes which refer to the same namespace. This is described in this post.
If you look at a sample from the site you quoted (http://www.w3schools.com/schema/default.asp) you will see that the xs namespace prefix refers to http://www.w3.org/2001/XMLSchema which is the same as xsd in the Tridion schema.
E.g.
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
therefore xsd is the same as xs.
Or am I completely missing your point?
If you are just looking on how to apply restrictions, this comes from the SDL Tridion docs (here but requires password):
<xsd:element name="NumberFieldWithMultipleFacets">
<xsd:simpleType>
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="4"/>
<xsd:fractionDigits value="2"/>
<xsd:minInclusive value="10"/>
<xsd:maxInclusive value="20"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
If you are looking for a list of the possible facets in Xml Schema, then you need to look here. Perhaps then it's a simple matter to check which of these are respected/supported by Tridion
I still miss xsd:ID for example, works in WebForms (yes, from version 1.0), but not in the latest SDL Tridion GUI (except 2013, not tested).
I would like all valid xsd's to work in the Tridion GUI.
And for example, that content editors will see a counter when you limit a text field to be min="30" max="70" characters.
Would be a very nice GUI update.
Because it would make WebForms possible in the normal(!) Tridion GUI.
Creating new fields will then be possible by content management.
Creating new HTML5 webforms (tested!) takes then less then 2 minutes.
So please update the GUI to full xsd support.
Hi all i am an XML Schema where i have the following
<xsd:element name="Check" type="CheckboxType">
<xsd:annotation>
<xsd:documentation>
<Description>Check</Description>
<LineNumber>12</LineNumber>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
While assigning the value or inner text for this field it is taking only X. What's the other value that i can pass other than X. I think X is assigned when i checked a check box, but what's the other value that i can assign to that Node when check box was not checked
There are multiple ways to specify an absence of a value. Below two are two generic ways.
Option 1
Do not add the element in the XML instance. If this is the right option or not is dependent upon the context and hard to tell without knowing more information
Option 2
Use xsi:nil="true" attribute in the XML instance. You can read more about the usage on zvon.org. To use this change your element definition as below
<xsd:element name="Check" type="CheckboxType" nillable="true">
<xsd:annotation>
<xsd:documentation>
<Description>Check</Description>
<LineNumber>12</LineNumber>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
You can then have the XML instance as below
<Check xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />