Is there a DTD available for xsp-config file? - xpages
I am developing a Java Control using this tutorial. For it I need to create MyJavaControl.xsp-config and edit it. This link details out the file format of xsp-config file and its various tags.
I would like to know is there a complete DTD available anywhere for xsp-config file? The reason I need the DTD is so that I can include in DOCTYPE of XML giving content assist in Domino Designer.
According to http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPages_configuration_file_format the xsp-config format is based on JSF's existing faces-config format. So, you can use http://java.sun.com/dtd/web-facesconfig_1_1.dtd for validation.
If you create your components, but don't want to have them visible in Domino Designer controls palette, then you should be safe to use JSF 1.1 DTD
I created a DTD using the definitions given in XPages configuration file format. The DTD is NOT complete and would have incomplete elements for sure. If you come across any feel free to edit the answer or leave a comment.
<!ELEMENT faces-config ((application | factory | component | converter | managed-bean | navigation-rule | referenced-bean | render-kit | lifecycle | validator | complex-type | composite-component | group | faces-config-extension )*)>
<!ELEMENT faces-config-extension ANY>
<!ELEMENT component (description*, display-name*, icon*, component-type, component-class, facet*, group-type-ref*, attribute*, property*, component-extension*)>
<!ELEMENT component-extension ANY>
<!ELEMENT facet (description*, display-name*, icon*, facet-name, facet-extension*)>
<!ELEMENT facet-extension ANY>
<!ELEMENT base-component-type (#PCDATA)>
<!ELEMENT component-class (#PCDATA)>
<!ELEMENT component-type (#PCDATA)>
<!ELEMENT group-type-ref (#PCDATA)>
<!ELEMENT tag-name (#PCDATA)>
<!ELEMENT property (description*, display-name*, icon*, property-name, property-class, default-value?, suggested-value?, property-extension*)>
<!ELEMENT property-extension ANY>
<!ELEMENT attribute (description*, display-name*, icon*, attribute-name, attribute-class, default-value?, suggested-value?, attribute-extension*)>
<!ELEMENT attribute-extension ANY>
<!ELEMENT allow-load-time-binding (#PCDATA)>
<!ELEMENT allow-non-binding (#PCDATA)>
<!ELEMENT allow-run-time-binding (#PCDATA)>
<!ELEMENT collection-property (#PCDATA)>
<!ELEMENT container-class (#PCDATA)>
<!ELEMENT localizable (#PCDATA)>
<!ELEMENT method-binding-property (#PCDATA)>
<!ELEMENT method-param (method-param-name, method-param-class) >
<!ELEMENT method-param-name (#PCDATA)>
<!ELEMENT method-param-class (#PCDATA)>
<!ELEMENT method-return-type (#PCDATA)>
<!ELEMENT property-add-method (#PCDATA)>
<!ELEMENT property-class (#PCDATA)>
<!ELEMENT property-item-class (#PCDATA)>
<!ELEMENT property-name (#PCDATA)>
<!ELEMENT required (#PCDATA)>
<!ELEMENT tag-attribute (#PCDATA)>
<!ELEMENT complex-type (description*, display-name*, icon*, complex-id, complex-class, group-type-ref*, property*, complex-extension*)>
<!ELEMENT complex-extension ANY>
<!ELEMENT converter (description*, display-name*, icon*, (converter-id | converter-for-class), converter-class, group-type-ref*, attribute*, property*, converter-extension*)>
<!ELEMENT converter-extension ANY>
<!ELEMENT validator (description*, display-name*, icon*, validator-id, validator-class, group-type-ref*, attribute*, property*, validator-extension*)>
<!ELEMENT validator-extension ANY>
<!ELEMENT base-complex-id (#PCDATA)>
<!ELEMENT base-converter-id (#PCDATA)>
<!ELEMENT base-validator-id (#PCDATA)>
<!ELEMENT complex-class (#PCDATA)>
<!ELEMENT complex-id (#PCDATA)>
<!ELEMENT converter-id (#PCDATA)>
<!ELEMENT default-property (#PCDATA)>
<!ELEMENT validator-id (#PCDATA)>
<!ELEMENT composite-component (description*, display-name*, icon*, component-type, composite-name, composite-file, facet*, group-type-ref*, attribute*, property*, property-type*, composite-extension*)>
<!ELEMENT composite-extension ANY>
<!ELEMENT property-type (description*, display-name*, icon*, property-name, property*, property-type*, property-extension*)>
<!ELEMENT group (description*, display-name*, icon*, group-type, group-type-ref*, property*, group-extension*)>
<!ELEMENT group-extension ANY>
<!ELEMENT render-kit (description*, display-name*, icon*, render-kit-id?, render-kit-class?, renderer*, render-kit-extension?)>
<!ELEMENT render-kit-extension ANY>
<!ELEMENT renderer (description*, display-name*, icon*, component-family, renderer-type, renderer-class, facet*, attribute*, renderer-extension*)>
<!ELEMENT renderer-extension ANY>
<!ELEMENT base-render-kit-id (#PCDATA)>
<!ELEMENT component-family (#PCDATA)>
<!ELEMENT composite-file (#PCDATA)>
<!ELEMENT composite-name (#PCDATA)>
<!ELEMENT group-type (#PCDATA)>
<!ELEMENT render-kit-alias (#PCDATA)>
<!ELEMENT renderer-type (#PCDATA)>
<!ELEMENT icon (small-icon?, large-icon?)>
<!ELEMENT small-icon (#PCDATA)>
<!ELEMENT large-icon (#PCDATA)>
<!-- Added 8 July 2013 -->
<!ELEMENT designer-extension (category, selected-event, event, visible, subcategory, in-palette, generate-id, render-markup, is-deprecated)>
<!ELEMENT category (#PCDATA)>
<!ELEMENT selected-event (#PCDATA)>
<!ELEMENT event (#PCDATA)>
<!ELEMENT visible (true|false)>
<!ELEMENT subcategory (#PCDATA)>
<!ELEMENT in-palette (true|false)>
<!ELEMENT generate-id (true|false)>
<!ELEMENT render-markup (#PCDATA)>
<!ELEMENT is-deprecated (true|false)>
Save the above code in a DTD file and include it in your xsp-config using below code:
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"D:\DTDs\xspconfig.dtd">
Related
XSD validation error - choice is invalid, misplaced, or occurs too often [duplicate]
This question already has answers here: Where does xsd:attribute declaration go? (A problem was found starting at: attribute.) (1 answer) How to make type depend on attribute value using Conditional Type Assignment (1 answer) Value of XML element depends on values of other elements in XSD? (1 answer) Closed 17 days ago. I have a problem with validation of the case that if attribute "brand" has value "x" then it is required to use attribute "model" otherwise attribute "model" should not be used. XSD part which I am using for that is as below : <?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name = "deviceList" type="deviceType"/> <xs:complexType name="deviceType"> <xs:attribute name="brand" type="xs:string"/> <xs:attribute name="model" type="xs:string" use="prohibited"/> <xs:choice> <xs:sequence> <xs:attribute name="A" use="required" fixed="1"/> <xs:attribute name="B" use="required"/> </xs:sequence> <xs:attribute name="A" use="required"/> </xs:choice> </xs:complexType> </xs:schema> When validating the result is : The content of 'variableType' is invalid. Element 'choice' is invalid, misplaced, or occurs too often. To be fair I don't know why it is not validating properly ... XML part which I am trying to validate: <?xml version="1.1"?> <!-- <deviceMappingFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XSD file.xsd"> --> <deviceList brand="x" model="yyy( model required if brand=x , if other not in use))"/>
Predefined attributes/constants in xsd enumeration
I have the following xml: <animals> <animal name="Pongo" animalType="Dog" /> <animal name="Marie" animalType="Cat" /> <animal name="Skippy" animalType="Kangaroo" /> </animals> I know it is possible to restrict the type of animals using an enum like this: <xs:simpleType name="animalType"> <xs:restriction base="xs:string"> <xs:enumeration value="Cat" /> <xs:enumeration value="Dog" /> <xs:enumeration value="Kangaroo" /> </xs:restriction> </xs:simpleType> What I whould like is to know automatically, based on the animalType value, how many shoes does the animal need, after the xml parsing. And, when a new animal type is being added, to add also the number of walking legs for that animal. For instance, it would be great to be possible to define something like <xs:simpleType name="animalType"> <xs:restriction base="xs:string"> <xs:enumeration value="Cat" nbOfShoes="4" /> <xs:enumeration value="Dog" nbOfShoes="4" /> <xs:enumeration value="Kangaroo" nbOfShoes="2" /> </xs:restriction> </xs:simpleType> Is it possible to achieve this using xsd, or I have to implement the numberOfShoes logic after the xml is being parsed? Thank you.
It depends. In XSD you can define xml from structure point of view. The relation between structure and content is more difficult to express in XSD 1.0. You could use substitution of types using xsi:type attribute. The XSD could look like <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- Let be Animals root element --> <xs:element name="Animals" type="animals" /> <!-- type for Animals elemes --> <xs:complexType name="animals"> <xs:sequence> <xs:element name="Animal" maxOccurs="unbounded" type="animal"/> </xs:sequence> </xs:complexType> <!-- Define an abstract type for animal (abstract = there shouldn't occure element of this type only of its childs). It has no attributes. --> <xs:complexType name="animal" abstract="true"> <xs:simpleContent> <xs:extension base="xs:string"/> </xs:simpleContent> </xs:complexType> <!-- Define a type for cat... --> <xs:complexType name="catType"> <xs:simpleContent> <!-- ... it extends abstract animal type ... --> <xs:extension base="animal"> <!-- ... and add some attributes with fixed values --> <xs:attribute name="name" fixed="cat" /> <xs:attribute name="nbOfLegs" fixed="4" /> </xs:extension> </xs:simpleContent> </xs:complexType> <!-- similar definition like catType --> <xs:complexType name="kangarooType"> <xs:simpleContent> <xs:extension base="animal"> <xs:attribute name="name" fixed="kangaroo" /> <xs:attribute name="nbOfLegs" fixed="2" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema> Following XML should validate <?xml version="1.0" encoding="UTF-8"?> <Animals xsi:noNamespaceSchemaLocation="animals.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- xsi:type is saying what type is actually used --> <Animal xsi:type="catType" name="cat" nbOfLegs="4" /> <Animal xsi:type="kangarooType" name="kangaroo" nbOfLegs="2" /> </Animals> Following not <?xml version="1.0" encoding="UTF-8"?> <Animals xsi:noNamespaceSchemaLocation="animals.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Animal xsi:type="catType" name="cat" nbOfLegs="2" /> </Animals> (with error like Value '2' of attribute 'nbOfLegs' is not equal to the fixed default value '4').
How to constrain set of attributes in xsd
All Please suggest me how to restrict in xsd schema the following: <root> <node action="action1" parameter="1" /> </root> I need to require attribute "parameter" only if attribute "action" is defined. Thanks,
W3C Schema doesn't have the ability to express conditionally required attributes. Schematron is a great tool for validating that documents adhere to custom validation scenarios in which content is conditionally required. You could define those attributes as optional in your schema, and then use Schematron to validate it against those conditional rules.
I created this xsd to attempt to solve the problem. <?xml version="1.0" encoding="utf-8"?> <xs:schema id="XMLSchema1" targetNamespace="http://tempuri.org/XMLSchema1.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema1.xsd" xmlns:mstns="http://tempuri.org/XMLSchema1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:group name="populated"> <xs:sequence > <xs:element name="node"> <xs:complexType> <xs:attributeGroup ref="actionattrib" /> </xs:complexType> </xs:element> </xs:sequence> </xs:group> <xs:group name="unpopulated"> <xs:sequence > <xs:element name="node"> <xs:complexType> </xs:complexType> </xs:element> </xs:sequence> </xs:group> <xs:attributeGroup name ="actionattrib"> <xs:attribute name="action1" type="xs:string" /> <xs:attribute name="parameter" type="xs:int" /> </xs:attributeGroup> <xs:element name="root"> <xs:complexType> <xs:choice minOccurs ="0"> <xs:group ref="populated" /> <xs:group ref ="unpopulated" /> </xs:choice> </xs:complexType> </xs:element> </xs:schema> And a test method: public static void Go() { string nameSpace = "http://tempuri.org/XMLSchema1.xsd"; XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add(nameSpace, "XMLSchema1.xsd"); XDocument myDoc1 = new XDocument( new XElement(XName.Get("root", nameSpace), new XElement( XName.Get("node", nameSpace )) ) ); myDoc1.Validate(schemas, (o, e) => { Console.WriteLine(e.Message); }); } And finally got this exception when validating: Multiple definition of element 'http://tempuri.org/XMLSchema1.xsd:node' causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence. Which matches Mads result. His answer should be accepted.
XSD restricting an xsd type while also allowing attributes
I am new to XML and I am working on XSDs at the moment. I am supposed to validate an xml document that is based on credit cards. I have worked through most of the assignment, but I am stuck on declaring an element that must be a positive floating point number, while also allowing that element to have a required attribute, which must have a 3 letter currency type associated with it. Here is an example of the XML element I have to validate: <total curId="USD">4003.46</total> Here is what I have: <xsd:element name="total" type="validAmount"/> <xsd:complexType name="validAmount"> <xsd:simpleContent> <xsd:extension base="xsd:decimal"> <xsd:attribute name= "curId" type = "currencyAttribute" use="required"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> For the curId attribute: <xsd:simpleType name="currencyAttribute"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Z]{3}"/> </xsd:restriction> </xsd:simpleType> The problem I am having is trying to change the extension to a restriction, allowing the decimal to be a positive number (perhaps changing its type to a string and using a pattern facet to restrict it to a positive number). However the script I am using to validate the xml doc throws errors if I do so. I know I am probably missing something painfully obvious, but like I said, I am new to this so any help would be greatly appreciated.
http://www.w3.org/TR/xmlschema-2/#decimal This type can be restricted using the minInclusive facet, which does what you want.
XSD doesn't allow you to achieve what you want in one "shot"; you need to first define a restricted simple type (below in restrictedDecimal type), and then extend that with attributes (the key here being the use of simpleContent). <?xml version="1.0" encoding="utf-8" ?> <!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) --> <xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="total" type="validAmount"/> <xsd:simpleType name="restrictedDecimal"> <xsd:restriction base="xsd:decimal"> <xsd:minInclusive value="0"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="validAmount"> <xsd:simpleContent> <xsd:extension base="restrictedDecimal"> <xsd:attribute name= "curId" type = "currencyAttribute" use="required"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:simpleType name="currencyAttribute"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Z]{3}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema>
XML Schema: How to specify an attribute with a custom 'simpleType' type?
In my XML schema definition, I'm trying to restrict the value of an attribute to be an integer between 0 and 100. With reference to the sample schema below, I want attribute 'attr' on element 'root' to have this restriction. To achieve this I define a simpleType 'Percentage' and set this as the 'type' of 'attr'. However, my XML schema editor (VS 2008) flags the attribute up as having a problem: "Type 'Percentage' is not declared or is not a simple type". <?xml version="1.0" encoding="utf-8"?> <xs:schema elementFormDefault="qualified" id="test" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://testtttt"> <xs:simpleType name="Percentage"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> <xs:element name="root"> <xs:complexType> <xs:attribute name="attr" type="Percentage" use="optional" /> </xs:complexType> </xs:element>
It looks like you are missing a namespace declaration on your schema root element: xmlns="http://testtttt" So the type reference is invalid.