| 1 | package Net::Amazon::MechanicalTurk::QAPValidator; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Net::Amazon::MechanicalTurk::BaseObject; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 0 | ▶ | use Net::Amazon::MechanicalTurk::ModuleUtil; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 6 | |||
| 7 | our $VERSION = '1.00'; | ||
| 8 | |||
| 9 | our @ISA = qw{ Net::Amazon::MechanicalTurk::BaseObject }; | ||
| 10 | |||
| 11 | #TODO: Write an implementation for LibXML or Xerces | ||
| 12 | our @IMPLEMENTATIONS = qw{ | ||
| 13 | Net::Amazon::MechanicalTurk::QAPValidator::QAPValidatorMSXML | ||
| 14 | }; | ||
| 15 | |||
| 16 | our $QUESTION_FORM_SCHEMA_2005_10_01; | ||
| 17 | our $QUESTION_FORM_NAMESPACE_2005_10_01 = "http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd"; | ||
| 18 | |||
| 19 | sub questionFormNamespace { | ||
| 20 | return $QUESTION_FORM_NAMESPACE_2005_10_01; | ||
| 21 | } | ||
| 22 | |||
| 23 | sub questionFormXSD { | ||
| 24 | return $QUESTION_FORM_SCHEMA_2005_10_01; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub create { | ||
| 28 | my $self = shift; | ||
| 29 | my $module = Net::Amazon::MechanicalTurk::ModuleUtil->requireFirst(@IMPLEMENTATIONS); | ||
| 30 | return $module->new(@_); | ||
| 31 | } | ||
| 32 | |||
| 33 | $QUESTION_FORM_SCHEMA_2005_10_01 = <<END_XML; | ||
| 34 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 35 | <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd" targetNamespace="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified"> | ||
| 36 | <xs:element name="QuestionForm"> | ||
| 37 | <xs:complexType> | ||
| 38 | <xs:sequence> | ||
| 39 | <xs:element name="Overview" type="tns:ContentType" minOccurs="0"/> | ||
| 40 | <xs:element name="Question" maxOccurs="unbounded"> | ||
| 41 | <xs:complexType> | ||
| 42 | <xs:sequence> | ||
| 43 | <xs:element name="QuestionIdentifier" type="xs:string"/> | ||
| 44 | <xs:element name="DisplayName" type="xs:string" minOccurs="0"/> | ||
| 45 | <xs:element name="IsRequired" type="xs:boolean" minOccurs="0"/> | ||
| 46 | <xs:element name="QuestionContent" type="tns:ContentType"/> | ||
| 47 | <xs:element name="AnswerSpecification" type="tns:AnswerSpecificationType"/> | ||
| 48 | </xs:sequence> | ||
| 49 | </xs:complexType> | ||
| 50 | </xs:element> | ||
| 51 | </xs:sequence> | ||
| 52 | </xs:complexType> | ||
| 53 | </xs:element> | ||
| 54 | <xs:complexType name="AnswerSpecificationType"> | ||
| 55 | <xs:choice> | ||
| 56 | <xs:element name="FreeTextAnswer" type="tns:FreeTextAnswerType"/> | ||
| 57 | <xs:element name="SelectionAnswer" type="tns:SelectionAnswerType"/> | ||
| 58 | <xs:element name="FileUploadAnswer" type="tns:FileUploadAnswerType"/> | ||
| 59 | </xs:choice> | ||
| 60 | </xs:complexType> | ||
| 61 | <xs:complexType name="ContentType"> | ||
| 62 | <xs:choice maxOccurs="unbounded"> | ||
| 63 | <xs:element name="Title" type="xs:string"/> | ||
| 64 | <xs:element name="Text" type="xs:string"/> | ||
| 65 | <xs:element name="List"> | ||
| 66 | <xs:complexType> | ||
| 67 | <xs:sequence> | ||
| 68 | <xs:element name="ListItem" type="xs:string" maxOccurs="unbounded"/> | ||
| 69 | </xs:sequence> | ||
| 70 | </xs:complexType> | ||
| 71 | </xs:element> | ||
| 72 | <xs:element name="FormattedContent" type="xs:string"/> | ||
| 73 | <xs:element name="Binary" type="tns:BinaryContentType"/> | ||
| 74 | <xs:element name="Application" type="tns:ApplicationContentType"/> | ||
| 75 | <xs:element name="EmbeddedBinary" type="tns:EmbeddedBinaryContentType"/> | ||
| 76 | </xs:choice> | ||
| 77 | </xs:complexType> | ||
| 78 | |||
| 79 | <xs:complexType name="ApplicationContentType"> | ||
| 80 | <xs:choice> | ||
| 81 | <xs:element name="Flash" type="tns:FlashContentType"/> | ||
| 82 | <xs:element name="JavaApplet" type="tns:JavaAppletContentType"/> | ||
| 83 | </xs:choice> | ||
| 84 | </xs:complexType> | ||
| 85 | <xs:complexType name="FlashContentType"> | ||
| 86 | <xs:sequence> | ||
| 87 | <xs:element name="FlashMovieURL" type="tns:URLType" /> | ||
| 88 | <xs:element name="Width" type="xs:string" /> | ||
| 89 | <xs:element name="Height" type="xs:string" /> | ||
| 90 | <xs:element name="ApplicationParameter" type="tns:ApplicationParameter" minOccurs="0" maxOccurs="unbounded"/> | ||
| 91 | </xs:sequence> | ||
| 92 | </xs:complexType> | ||
| 93 | |||
| 94 | <xs:complexType name="JavaAppletContentType"> | ||
| 95 | <xs:sequence> | ||
| 96 | <xs:element name="AppletPath" type="tns:URLType" /> | ||
| 97 | <xs:element name="AppletFilename" type="xs:string" /> | ||
| 98 | <xs:element name="Width" type="xs:string"/> | ||
| 99 | <xs:element name="Height" type="xs:string" /> | ||
| 100 | <xs:element name="ApplicationParameter" type="tns:ApplicationParameter" minOccurs="0" maxOccurs="unbounded"/> | ||
| 101 | </xs:sequence> | ||
| 102 | </xs:complexType> | ||
| 103 | |||
| 104 | <xs:complexType name="MimeType"> | ||
| 105 | <xs:sequence> | ||
| 106 | <xs:element name="Type"> | ||
| 107 | <xs:simpleType> | ||
| 108 | <xs:restriction base="xs:string"> | ||
| 109 | <xs:enumeration value="image"/> | ||
| 110 | <xs:enumeration value="audio"/> | ||
| 111 | <xs:enumeration value="video"/> | ||
| 112 | </xs:restriction> | ||
| 113 | </xs:simpleType> | ||
| 114 | </xs:element> | ||
| 115 | <xs:element name="SubType" type="xs:string" minOccurs="0"/> | ||
| 116 | </xs:sequence> | ||
| 117 | </xs:complexType> | ||
| 118 | |||
| 119 | <!-- Content of this type opens a new window --> | ||
| 120 | <xs:complexType name="BinaryContentType"> | ||
| 121 | <xs:sequence> | ||
| 122 | <xs:element name="MimeType" type="tns:MimeType"/> | ||
| 123 | <xs:element name="DataURL" type="tns:URLType"/> | ||
| 124 | <xs:element name="AltText" type="xs:string"/> | ||
| 125 | </xs:sequence> | ||
| 126 | </xs:complexType> | ||
| 127 | |||
| 128 | <xs:complexType name="EmbeddedMimeType"> | ||
| 129 | <xs:sequence> | ||
| 130 | <xs:element name="Type" type="xs:string" /> | ||
| 131 | <xs:element name="SubType" type="xs:string" /> | ||
| 132 | </xs:sequence> | ||
| 133 | </xs:complexType> | ||
| 134 | |||
| 135 | |||
| 136 | <!-- Content of this type displays within the user's browser, plug-in dependent --> | ||
| 137 | |||
| 138 | <xs:complexType name="EmbeddedBinaryContentType"> | ||
| 139 | <xs:sequence> | ||
| 140 | <xs:element name="EmbeddedMimeType" type="tns:EmbeddedMimeType"/> | ||
| 141 | <xs:element name="DataURL" type="tns:URLType"/> | ||
| 142 | <xs:element name="AltText" type="xs:string"/> | ||
| 143 | <xs:element name="Width" type="xs:string"/> | ||
| 144 | <xs:element name="Height" type="xs:string"/> | ||
| 145 | <xs:element name="ApplicationParameter" type="tns:ApplicationParameter" minOccurs="0" maxOccurs="unbounded"/> | ||
| 146 | </xs:sequence> | ||
| 147 | </xs:complexType> | ||
| 148 | |||
| 149 | <xs:complexType name="FreeTextAnswerType"> | ||
| 150 | <xs:sequence> | ||
| 151 | <xs:element name="Constraints" minOccurs="0"> | ||
| 152 | <xs:complexType> | ||
| 153 | <xs:sequence> | ||
| 154 | <xs:element name="IsNumeric" minOccurs="0"> | ||
| 155 | <xs:complexType> | ||
| 156 | <xs:simpleContent> | ||
| 157 | <xs:extension base="xs:anySimpleType"> | ||
| 158 | <xs:attribute name="minValue" type="xs:int" use="optional"/> | ||
| 159 | <xs:attribute name="maxValue" type="xs:int" use="optional"/> | ||
| 160 | </xs:extension> | ||
| 161 | </xs:simpleContent> | ||
| 162 | </xs:complexType> | ||
| 163 | </xs:element> | ||
| 164 | <xs:element name="Length" minOccurs="0"> | ||
| 165 | <xs:complexType> | ||
| 166 | <xs:simpleContent> | ||
| 167 | <xs:extension base="xs:anySimpleType"> | ||
| 168 | <xs:attribute name="minLength" type="xs:nonNegativeInteger" use="optional"/> | ||
| 169 | <xs:attribute name="maxLength" type="xs:positiveInteger" use="optional"/> | ||
| 170 | </xs:extension> | ||
| 171 | </xs:simpleContent> | ||
| 172 | </xs:complexType> | ||
| 173 | </xs:element> | ||
| 174 | </xs:sequence> | ||
| 175 | </xs:complexType> | ||
| 176 | </xs:element> | ||
| 177 | <xs:element name="DefaultText" type="xs:string" minOccurs="0"/> | ||
| 178 | <xs:element name="NumberOfLinesSuggestion" type="xs:positiveInteger" minOccurs="0"/> | ||
| 179 | </xs:sequence> | ||
| 180 | </xs:complexType> | ||
| 181 | <xs:complexType name="SelectionAnswerType"> | ||
| 182 | <xs:sequence> | ||
| 183 | <xs:element name="MinSelectionCount" type="xs:nonNegativeInteger" minOccurs="0"/> | ||
| 184 | <xs:element name="MaxSelectionCount" type="xs:positiveInteger" minOccurs="0"/> | ||
| 185 | <xs:element name="StyleSuggestion" minOccurs="0"> | ||
| 186 | <xs:simpleType> | ||
| 187 | <xs:restriction base="xs:string"> | ||
| 188 | <xs:enumeration value="radiobutton"/> | ||
| 189 | <xs:enumeration value="checkbox"/> | ||
| 190 | <xs:enumeration value="list"/> | ||
| 191 | <xs:enumeration value="dropdown"/> | ||
| 192 | <xs:enumeration value="combobox"/> | ||
| 193 | <xs:enumeration value="multichooser"/> | ||
| 194 | </xs:restriction> | ||
| 195 | </xs:simpleType> | ||
| 196 | </xs:element> | ||
| 197 | <xs:element name="Selections"> | ||
| 198 | <xs:complexType> | ||
| 199 | <xs:sequence> | ||
| 200 | <xs:element name="Selection" maxOccurs="unbounded"> | ||
| 201 | <xs:complexType> | ||
| 202 | <xs:sequence> | ||
| 203 | <xs:element name="SelectionIdentifier" type="xs:string"/> | ||
| 204 | <xs:choice> | ||
| 205 | <xs:element name="Text" type="xs:string"/> | ||
| 206 | <xs:element name="Binary" type="tns:BinaryContentType"/> | ||
| 207 | </xs:choice> | ||
| 208 | </xs:sequence> | ||
| 209 | </xs:complexType> | ||
| 210 | </xs:element> | ||
| 211 | <xs:element name="OtherSelection" type="tns:FreeTextAnswerType" minOccurs="0"/> | ||
| 212 | </xs:sequence> | ||
| 213 | </xs:complexType> | ||
| 214 | </xs:element> | ||
| 215 | </xs:sequence> | ||
| 216 | </xs:complexType> | ||
| 217 | |||
| 218 | <xs:complexType name="FileUploadAnswerType"> | ||
| 219 | <xs:sequence> | ||
| 220 | <xs:element type="tns:MaxFileSizeType" name="MaxFileSizeInBytes"/> | ||
| 221 | <xs:element type="tns:MinFileSizeType" name="MinFileSizeInBytes"/> | ||
| 222 | </xs:sequence> | ||
| 223 | </xs:complexType> | ||
| 224 | |||
| 225 | <xs:simpleType name="MaxFileSizeType"> | ||
| 226 | <xs:restriction base="xs:positiveInteger"> | ||
| 227 | <xs:maxInclusive value="2000000000"/> | ||
| 228 | </xs:restriction> | ||
| 229 | </xs:simpleType> | ||
| 230 | |||
| 231 | <xs:simpleType name="MinFileSizeType"> | ||
| 232 | <xs:restriction base="xs:positiveInteger"> | ||
| 233 | <xs:maxInclusive value="2000000000"/> | ||
| 234 | </xs:restriction> | ||
| 235 | </xs:simpleType> | ||
| 236 | |||
| 237 | <xs:simpleType name="URLType"> | ||
| 238 | <xs:restriction base="xs:anyURI"> | ||
| 239 | <xs:pattern value="(http|https)://.*"/> | ||
| 240 | </xs:restriction> | ||
| 241 | </xs:simpleType> | ||
| 242 | |||
| 243 | |||
| 244 | <xs:complexType name="ApplicationParameter"> | ||
| 245 | <xs:sequence> | ||
| 246 | <xs:element name="Name" type="xs:string" /> | ||
| 247 | <xs:element name="Value" type="xs:string" /> | ||
| 248 | </xs:sequence> | ||
| 249 | </xs:complexType> | ||
| 250 | |||
| 251 | </xs:schema> | ||
| 252 | END_XML | ||
| 253 | |||
| 254 | return 1; | ||