1 55 package org.jboss.axis.wsdl.symbolTable; 56 57 import org.jboss.axis.Constants; 58 import org.w3c.dom.Node ; 59 import org.w3c.dom.NodeList ; 60 61 import javax.xml.namespace.QName ; 62 import javax.xml.rpc.holders.BooleanHolder ; 63 import javax.xml.rpc.holders.IntHolder ; 64 import java.util.Arrays ; 65 import java.util.HashSet ; 66 import java.util.Set ; 67 import java.util.Vector ; 68 69 74 public class SchemaUtils 75 { 76 77 static final QName VALUE_QNAME = Utils.findQName("", "value"); 78 79 92 public static Vector getContainedElementDeclarations(Node node, SymbolTable symbolTable) 93 { 94 if (node == null) 95 { 96 return null; 97 } 98 99 if (isXSDNode(node, "element")) 101 { 102 NodeList children = node.getChildNodes(); 103 for (int j = 0; j < children.getLength(); j++) 104 { 105 Node kid = children.item(j); 106 if (isXSDNode(kid, "complexType")) 107 { 108 node = kid; 109 break; 110 } 111 } 112 } 113 114 if (isXSDNode(node, "complexType")) 116 { 117 NodeList children = node.getChildNodes(); 120 Node complexContent = null; 121 Node simpleContent = null; 122 Node extension = null; 123 for (int j = 0; j < children.getLength(); j++) 124 { 125 Node kid = children.item(j); 126 if (isXSDNode(kid, "complexContent")) 127 { 128 complexContent = kid; 129 break; } 131 else if (isXSDNode(kid, "simpleContent")) 132 { 133 simpleContent = kid; 134 } 135 } 136 if (complexContent != null) 137 { 138 children = complexContent.getChildNodes(); 139 for (int j = 0; j < children.getLength() && extension == null; j++) 140 { 141 Node kid = children.item(j); 142 if (isXSDNode(kid, "extension")) 143 { 144 extension = kid; 145 } 146 } 147 } 148 if (simpleContent != null) 149 { 150 children = simpleContent.getChildNodes(); 151 for (int j = 0; j < children.getLength() && extension == null; j++) 152 { 153 QName extensionOrRestrictionKind = Utils.getNodeQName(children.item(j)); 154 if (extensionOrRestrictionKind != null && 155 (extensionOrRestrictionKind.getLocalPart().equals("extension") || 156 extensionOrRestrictionKind.getLocalPart().equals("restriction")) && 157 Constants.isSchemaXSD(extensionOrRestrictionKind.getNamespaceURI())) 158 { 159 160 QName extendsOrRestrictsType = 162 Utils.getTypeQName(children.item(j), new BooleanHolder (), false); 163 164 Vector v = new Vector (); 167 ElementDecl elem = new ElementDecl(); 168 elem.setType(symbolTable.getTypeEntry(extendsOrRestrictsType, false)); 169 elem.setName(VALUE_QNAME); 170 v.add(elem); 171 return v; 172 } 173 } 174 } 175 176 if (extension != null) 177 { 178 node = extension; } 180 181 children = node.getChildNodes(); 184 Vector v = new Vector (); 185 for (int j = 0; j < children.getLength(); j++) 186 { 187 QName subNodeKind = Utils.getNodeQName(children.item(j)); 188 if (subNodeKind != null && 189 Constants.isSchemaXSD(subNodeKind.getNamespaceURI())) 190 { 191 if (subNodeKind.getLocalPart().equals("sequence")) 192 { 193 v.addAll(processSequenceNode(children.item(j), symbolTable)); 194 } 195 else if (subNodeKind.getLocalPart().equals("all")) 196 { 197 v.addAll(processAllNode(children.item(j), symbolTable)); 198 } 199 else if (subNodeKind.getLocalPart().equals("choice")) 200 { 201 v.addAll(processChoiceNode(children.item(j), symbolTable)); 202 } 203 else if (subNodeKind.getLocalPart().equals("group")) 204 { 205 v.addAll(processGroupNode(children.item(j), symbolTable)); 206 } 207 } 208 } 209 return v; 210 } 211 else 212 { 213 QName simpleQName = getSimpleTypeBase(node); 215 if (simpleQName != null) 216 { 217 TypeEntry simpleType = symbolTable.getType(simpleQName); 218 if (simpleType != null) 219 { 220 Vector v = new Vector (); 221 ElementDecl elem = new ElementDecl(); 222 elem.setType(simpleType); 223 elem.setName(new javax.xml.namespace.QName ("", "value")); 224 v.add(elem); 225 return v; 226 } 227 } 228 } 229 return null; 230 } 231 232 236 private static Vector processChoiceNode(Node choiceNode, 237 SymbolTable symbolTable) 238 { 239 Vector v = new Vector (); 240 NodeList children = choiceNode.getChildNodes(); 241 for (int j = 0; j < children.getLength(); j++) 242 { 243 QName subNodeKind = Utils.getNodeQName(children.item(j)); 244 if (subNodeKind != null && 245 Constants.isSchemaXSD(subNodeKind.getNamespaceURI())) 246 { 247 if (subNodeKind.getLocalPart().equals("choice")) 248 { 249 v.addAll(processChoiceNode(children.item(j), symbolTable)); 250 } 251 else if (subNodeKind.getLocalPart().equals("sequence")) 252 { 253 v.addAll(processSequenceNode(children.item(j), symbolTable)); 254 } 255 else if (subNodeKind.getLocalPart().equals("group")) 256 { 257 v.addAll(processGroupNode(children.item(j), symbolTable)); 258 } 259 else if (subNodeKind.getLocalPart().equals("element")) 260 { 261 ElementDecl elem = 262 processChildElementNode(children.item(j), 263 symbolTable); 264 if (elem != null) 265 v.add(elem); 266 } 267 } 268 } 269 return v; 270 } 271 272 276 private static Vector processSequenceNode(Node sequenceNode, 277 SymbolTable symbolTable) 278 { 279 Vector v = new Vector (); 280 NodeList children = sequenceNode.getChildNodes(); 281 for (int j = 0; j < children.getLength(); j++) 282 { 283 QName subNodeKind = Utils.getNodeQName(children.item(j)); 284 if (subNodeKind != null && 285 Constants.isSchemaXSD(subNodeKind.getNamespaceURI())) 286 { 287 if (subNodeKind.getLocalPart().equals("choice")) 288 { 289 v.addAll(processChoiceNode(children.item(j), symbolTable)); 290 } 291 else if (subNodeKind.getLocalPart().equals("sequence")) 292 { 293 v.addAll(processSequenceNode(children.item(j), symbolTable)); 294 } 295 else if (subNodeKind.getLocalPart().equals("group")) 296 { 297 v.addAll(processGroupNode(children.item(j), symbolTable)); 298 } 299 else if (subNodeKind.getLocalPart().equals("any")) 300 { 301 TypeEntry type = symbolTable.getType(Constants.XSD_ANY); 305 ElementDecl elem = 306 new ElementDecl(type, Utils.findQName("", "any")); 307 elem.setAnyElement(true); 308 v.add(elem); 309 } 310 else if (subNodeKind.getLocalPart().equals("element")) 311 { 312 ElementDecl elem = 313 processChildElementNode(children.item(j), 314 symbolTable); 315 if (elem != null) 316 v.add(elem); 317 } 318 } 319 } 320 return v; 321 } 322 323 329 private static Vector processGroupNode(Node groupNode, SymbolTable symbolTable) 330 { 331 Vector v = new Vector (); 332 NodeList children = groupNode.getChildNodes(); 333 for (int j = 0; j < children.getLength(); j++) 334 { 335 QName subNodeKind = Utils.getNodeQName(children.item(j)); 336 if (subNodeKind != null && 337 Constants.isSchemaXSD(subNodeKind.getNamespaceURI())) 338 { 339 if (subNodeKind.getLocalPart().equals("choice")) 340 { 341 v.addAll(processChoiceNode(children.item(j), symbolTable)); 342 } 343 else if (subNodeKind.getLocalPart().equals("sequence")) 344 { 345 v.addAll(processSequenceNode(children.item(j), symbolTable)); 346 } 347 else if (subNodeKind.getLocalPart().equals("all")) 348 { 349 v.addAll(processAllNode(children.item(j), symbolTable)); 350 } 351 } 352 } 353 return v; 354 } 355 356 360 private static Vector processAllNode(Node allNode, SymbolTable symbolTable) 361 { 362 Vector v = new Vector (); 363 NodeList children = allNode.getChildNodes(); 364 for (int j = 0; j < children.getLength(); j++) 365 { 366 Node kid = children.item(j); 367 if (isXSDNode(kid, "element")) 368 { 369 ElementDecl elem = processChildElementNode(kid, symbolTable); 370 if (elem != null) 371 { 372 v.add(elem); 373 } 374 } 375 } 376 return v; 377 } 378 379 380 387 private static ElementDecl processChildElementNode(Node elementNode, 388 SymbolTable symbolTable) 389 { 390 QName nodeName = Utils.getNodeNameQName(elementNode); 392 BooleanHolder forElement = new BooleanHolder (); 393 394 QName nodeType = Utils.getTypeQName(elementNode, forElement, false); 397 398 TypeEntry type = symbolTable.getTypeEntry(nodeType, forElement.value); 399 400 405 if (!forElement.value) 406 { 407 String form = Utils.getAttribute(elementNode, "form"); 410 if (form != null && form.equals("unqualified")) 411 { 412 nodeName = Utils.findQName("", nodeName.getLocalPart()); 414 } 415 else if (form == null) 416 { 417 String def = Utils.getScopedAttribute(elementNode, 419 "elementFormDefault"); 420 if (def == null || def.equals("unqualified")) 421 { 422 nodeName = Utils.findQName("", nodeName.getLocalPart()); 424 } 425 } 426 } 427 428 if (type != null) 429 { 430 ElementDecl elem = new ElementDecl(type, nodeName); 431 String minOccurs = Utils.getAttribute(elementNode, "minOccurs"); 432 if (minOccurs != null && minOccurs.equals("0")) 433 { 434 elem.setMinOccursIs0(true); 435 } 436 return elem; 437 } 438 439 return null; 440 } 441 442 446 public static QName getElementAnonQName(Node node) 447 { 448 if (isXSDNode(node, "element")) 449 { 450 NodeList children = node.getChildNodes(); 451 for (int j = 0; j < children.getLength(); j++) 452 { 453 Node kid = children.item(j); 454 if (isXSDNode(kid, "complexType") || isXSDNode(kid, "simpleType")) 455 { 456 return Utils.getNodeNameQName(kid); 457 } 458 } 459 } 460 return null; 461 } 462 463 467 public static QName getAttributeAnonQName(Node node) 468 { 469 if (isXSDNode(node, "attribute")) 470 { 471 NodeList children = node.getChildNodes(); 472 for (int j = 0; j < children.getLength(); j++) 473 { 474 Node kid = children.item(j); 475 if (isXSDNode(kid, "complexType") || isXSDNode(kid, "simpleType")) 476 { 477 return Utils.getNodeNameQName(kid); 478 } 479 } 480 } 481 return null; 482 } 483 484 487 public static boolean isSimpleTypeOrSimpleContent(Node node) 488 { 489 if (node == null) 490 { 491 return false; 492 } 493 494 if (isXSDNode(node, "element")) 496 { 497 NodeList children = node.getChildNodes(); 498 for (int j = 0; j < children.getLength(); j++) 499 { 500 Node kid = children.item(j); 501 if (isXSDNode(kid, "complexType")) 502 { 503 node = kid; 504 break; 505 } 506 else if (isXSDNode(kid, "simpleType")) 507 { 508 return true; 509 } 510 } 511 } 512 513 if (isXSDNode(node, "simpleType")) 515 { 516 return true; 517 } 518 519 if (isXSDNode(node, "complexType")) 520 { 521 NodeList children = node.getChildNodes(); 524 Node complexContent = null; 525 Node simpleContent = null; 526 for (int j = 0; j < children.getLength(); j++) 527 { 528 Node kid = children.item(j); 529 if (isXSDNode(kid, "complexContent")) 530 { 531 complexContent = kid; 532 break; 533 } 534 else if (isXSDNode(kid, "simpleContent")) 535 { 536 simpleContent = kid; 537 } 538 } 539 if (complexContent != null) 540 { 541 return false; 542 } 543 if (simpleContent != null) 544 { 545 return true; 546 } 547 } 548 return false; 549 } 550 551 563 private static boolean isXSDNode(Node node, String schemaLocalName) 564 { 565 if ((node != null) && Constants.isSchemaXSD(node.getNamespaceURI())) 566 { 567 String localName = node.getLocalName(); 568 return ((localName != null) && localName.equals(schemaLocalName)); 569 } 570 return false; 571 } 572 573 577 public static TypeEntry getComplexElementExtensionBase(Node node, SymbolTable symbolTable) 578 { 579 if (node == null) 580 { 581 return null; 582 } 583 584 TypeEntry cached = (TypeEntry)symbolTable.node2ExtensionBase.get(node); 585 if (cached != null) 586 { 587 return cached; } 589 590 if (isXSDNode(node, "element")) 592 { 593 NodeList children = node.getChildNodes(); 594 Node complexNode = null; 595 for (int j = 0; j < children.getLength() && complexNode == null; j++) 596 { 597 if (isXSDNode(children.item(j), "complexType")) 598 { 599 complexNode = children.item(j); 600 node = complexNode; 601 } 602 } 603 } 604 605 if (isXSDNode(node, "complexType")) 607 { 608 609 NodeList children = node.getChildNodes(); 612 Node content = null; 613 Node extension = null; 614 for (int j = 0; j < children.getLength() && content == null; j++) 615 { 616 Node kid = children.item(j); 617 if (isXSDNode(kid, "complexContent") || isXSDNode(kid, "simpleContent")) 618 { 619 content = kid; 620 } 621 } 622 if (content != null) 623 { 624 children = content.getChildNodes(); 625 for (int j = 0; j < children.getLength() && extension == null; j++) 626 { 627 Node kid = children.item(j); 628 if (isXSDNode(kid, "extension")) 629 { 630 extension = kid; 631 } 632 } 633 } 634 if (extension == null) 635 { 636 cached = null; 637 } 638 else 639 { 640 QName extendsType = Utils.getTypeQName(extension, new BooleanHolder (), false); 642 if (extendsType == null) 643 { 644 cached = null; 645 } 646 else 647 { 648 cached = symbolTable.getType(extendsType); 650 } 651 } 652 } 653 symbolTable.node2ExtensionBase.put(node, cached); 654 return cached; 655 } 656 657 661 public static QName getSimpleTypeBase(Node node) 662 { 663 QName baseQName = null; 664 665 if (node == null) 666 { 667 return null; 668 } 669 670 QName nodeKind = Utils.getNodeQName(node); 672 if (isXSDNode(node, "element")) 673 { 674 NodeList children = node.getChildNodes(); 675 for (int j = 0; j < children.getLength(); j++) 676 { 677 if (isXSDNode(children.item(j), "simpleType")) 678 { 679 node = children.item(j); 680 break; 681 } 682 } 683 } 684 if (isXSDNode(node, "simpleType")) 686 { 687 NodeList children = node.getChildNodes(); 690 Node restrictionNode = null; 691 for (int j = 0; j < children.getLength() && restrictionNode == null; j++) 692 { 693 if (isXSDNode(children.item(j), "restriction")) 694 { 695 restrictionNode = children.item(j); 696 } 697 } 698 699 702 if (restrictionNode != null) 703 { 704 baseQName = Utils.getTypeQName(restrictionNode, new BooleanHolder (), false); 705 } 706 707 if (baseQName != null && restrictionNode != null) 709 { 710 NodeList enums = restrictionNode.getChildNodes(); 711 for (int i = 0; i < enums.getLength(); i++) 712 { 713 if (isXSDNode(enums.item(i), "enumeration")) 714 { 715 return null; 718 } 719 } 720 } 721 } 722 return baseQName; 723 } 724 725 729 public static Node getRestrictionOrExtensionNode(Node node) 730 { 731 Node re = null; 732 if (node == null) 733 { 734 return re; 735 } 736 737 if (isXSDNode(node, "element")) 739 { 740 NodeList children = node.getChildNodes(); 741 Node node2 = null; 742 for (int j = 0; j < children.getLength(); j++) 743 { 744 Node n = children.item(j); 745 if (isXSDNode(n, "simpleType") || isXSDNode(n, "complexType") || isXSDNode(n, "simpleContent")) 746 { 747 node = n; 748 break; 749 } 750 } 751 } 752 if (isXSDNode(node, "simpleType") || isXSDNode(node, "complexType")) 754 { 755 NodeList children = node.getChildNodes(); 757 Node complexContent = null; 758 if (node.getLocalName().equals("complexType")) 759 { 760 for (int j = 0; j < children.getLength() && complexContent == null; j++) 761 { 762 Node kid = children.item(j); 763 if (isXSDNode(kid, "complexContent") || isXSDNode(kid, "simpleContent")) 764 { 765 complexContent = kid; 766 } 767 } 768 node = complexContent; 769 } 770 if (node != null) 772 { 773 children = node.getChildNodes(); 774 for (int j = 0; j < children.getLength() && re == null; j++) 775 { 776 Node kid = children.item(j); 777 if (isXSDNode(kid, "extension") || isXSDNode(kid, "restriction")) 778 { 779 re = kid; 780 } 781 } 782 } 783 } 784 785 return re; 786 } 787 788 796 public static QName getArrayComponentQName(Node node, IntHolder dims) 797 { 798 dims.value = 1; QName qName = getCollectionComponentQName(node); 800 if (qName == null) 801 { 802 qName = getArrayComponentQName_JAXRPC(node, dims); 803 } 804 return qName; 805 } 806 807 819 public static QName getCollectionComponentQName(Node node) 820 { 821 if (node == null) 822 { 823 return null; 824 } 825 826 if (isXSDNode(node, "element")) 828 { 829 BooleanHolder forElement = new BooleanHolder (); 832 QName componentQName = Utils.getTypeQName(node, forElement, true); 833 if (componentQName != null) 834 { 835 QName fullQName = Utils.getTypeQName(node, forElement, false); 836 if (!componentQName.equals(fullQName)) 837 { 838 return componentQName; 839 } 840 } 841 } 842 return null; 843 } 844 845 873 private static QName getArrayComponentQName_JAXRPC(Node node, IntHolder dims) 874 { 875 dims.value = 0; if (node == null) 877 { 878 return null; 879 } 880 881 if (isXSDNode(node, "element")) 883 { 884 NodeList children = node.getChildNodes(); 885 for (int j = 0; j < children.getLength(); j++) 886 { 887 Node kid = children.item(j); 888 if (isXSDNode(kid, "complexType")) 889 { 890 node = kid; 891 break; 892 } 893 } 894 } 895 896 if (isXSDNode(node, "complexType")) 898 { 899 NodeList children = node.getChildNodes(); 902 Node complexContentNode = null; 903 for (int j = 0; j < children.getLength(); j++) 904 { 905 Node kid = children.item(j); 906 if (isXSDNode(kid, "complexContent") || isXSDNode(kid, "simpleContent")) 907 { 908 complexContentNode = kid; 909 break; 910 } 911 } 912 913 Node restrictionNode = null; 916 if (complexContentNode != null) 917 { 918 children = complexContentNode.getChildNodes(); 919 for (int j = 0; j < children.getLength(); j++) 920 { 921 Node kid = children.item(j); 922 if (isXSDNode(kid, "restriction")) 923 { 924 restrictionNode = kid; 925 break; 926 } 927 } 928 } 929 930 QName baseType = null; 932 if (restrictionNode != null) 933 { 934 baseType = Utils.getTypeQName(restrictionNode, new BooleanHolder (), false); 935 if (baseType != null && 936 baseType.getLocalPart().equals("Array") && 937 Constants.isSOAP_ENC(baseType.getNamespaceURI())) 938 ; else 940 baseType = null; } 942 943 944 Node groupNode = null; 947 Node attributeNode = null; 948 if (baseType != null) 949 { 950 children = restrictionNode.getChildNodes(); 951 for (int j = 0; 952 j < children.getLength() && groupNode == null && attributeNode == null; 953 j++) 954 { 955 Node kid = children.item(j); 956 if (isXSDNode(kid, "sequence") || isXSDNode(kid, "all")) 957 { 958 groupNode = kid; 959 if (groupNode.getChildNodes().getLength() == 0) 960 { 961 groupNode = null; 971 } 972 } 973 if (isXSDNode(kid, "attribute")) 974 { 975 BooleanHolder isRef = new BooleanHolder (); 978 QName refQName = Utils.getTypeQName(kid, isRef, false); 979 if (refQName != null && 980 isRef.value && 981 refQName.getLocalPart().equals("arrayType") && 982 Constants.isSOAP_ENC(refQName.getNamespaceURI())) 983 { 984 attributeNode = kid; 985 } 986 } 987 } 988 } 989 990 if (attributeNode != null) 992 { 993 String wsdlArrayTypeValue = null; 994 Vector attrs = Utils.getAttributesWithLocalName(attributeNode, "arrayType"); 995 for (int i = 0; i < attrs.size() && wsdlArrayTypeValue == null; i++) 996 { 997 Node attrNode = (Node )attrs.elementAt(i); 998 String attrName = attrNode.getNodeName(); 999 QName attrQName = Utils.getQNameFromPrefixedName(attributeNode, attrName); 1000 if (Constants.isWSDL(attrQName.getNamespaceURI())) 1001 { 1002 wsdlArrayTypeValue = attrNode.getNodeValue(); 1003 } 1004 } 1005 1006 if (wsdlArrayTypeValue != null) 1011 { 1012 int i = wsdlArrayTypeValue.indexOf('['); 1013 if (i > 0) 1014 { 1015 String prefixedName = wsdlArrayTypeValue.substring(0, i); 1016 String mangledString = wsdlArrayTypeValue.replace(',', '['); 1017 dims.value = 0; 1018 int index = mangledString.indexOf('['); 1019 while (index > 0) 1020 { 1021 dims.value++; 1022 index = mangledString.indexOf('[', index + 1); 1023 } 1024 1025 return Utils.getQNameFromPrefixedName(restrictionNode, prefixedName); 1026 } 1027 } 1028 } 1029 else if (groupNode != null) 1030 { 1031 1032 NodeList elements = groupNode.getChildNodes(); 1034 Node elementNode = null; 1035 for (int i = 0; i < elements.getLength() && elementNode == null; i++) 1036 { 1037 Node kid = elements.item(i); 1038 if (isXSDNode(kid, "element")) 1039 { 1040 elementNode = elements.item(i); 1041 break; 1042 } 1043 } 1044 1045 if (elementNode != null) 1048 { 1049 String maxOccursValue = Utils.getAttribute(elementNode, "maxOccurs"); 1050 if (maxOccursValue != null && 1051 maxOccursValue.equalsIgnoreCase("unbounded")) 1052 { 1053 dims.value = 1; 1055 return Utils.getTypeQName(elementNode, new BooleanHolder (), true); 1056 } 1057 } 1058 } 1059 1060 } 1061 return null; 1062 } 1063 1064 1079 public static Vector getContainedAttributeTypes(Node node, 1080 SymbolTable symbolTable) 1081 { 1082 Vector v = null; 1084 if (node == null) 1085 { 1086 return null; 1087 } 1088 if (isXSDNode(node, "element")) 1091 { 1092 NodeList children = node.getChildNodes(); 1093 for (int j = 0; j < children.getLength(); j++) 1094 { 1095 Node kid = children.item(j); 1096 if (isXSDNode(kid, "complexType")) 1097 { 1098 node = kid; 1099 break; 1100 } 1101 } 1102 } 1103 1104 if (isXSDNode(node, "complexType")) 1106 { 1107 NodeList children = node.getChildNodes(); 1110 Node content = null; 1111 for (int j = 0; j < children.getLength(); j++) 1112 { 1113 Node kid = children.item(j); 1114 if (isXSDNode(kid, "complexContent") || isXSDNode(kid, "simpleContent")) 1115 { 1116 content = kid; 1117 break; 1118 } 1119 } 1120 if (content != null) 1122 { 1123 children = content.getChildNodes(); 1124 for (int j = 0; j < children.getLength(); j++) 1125 { 1126 Node kid = children.item(j); 1127 if (isXSDNode(kid, "extension")) 1128 { 1129 node = kid; 1130 break; 1131 } 1132 } 1133 } 1134 1135 children = node.getChildNodes(); 1137 for (int i = 0; i < children.getLength(); i++) 1138 { 1139 Node child = children.item(i); 1140 if (!isXSDNode(child, "attribute")) 1141 { 1142 continue; 1143 } 1144 1145 if (v == null) 1147 v = new Vector (); 1148 1149 QName attributeName = Utils.getNodeNameQName(child); 1153 BooleanHolder forElement = new BooleanHolder (); 1154 QName attributeType = Utils.getTypeQName(child, forElement, false); 1155 1156 if (!forElement.value) 1161 { 1162 String form = Utils.getAttribute(child, "form"); 1166 if (form != null && form.equals("unqualified")) 1167 { 1168 attributeName = Utils.findQName("", attributeName.getLocalPart()); 1170 } 1171 else if (form == null) 1172 { 1173 String def = Utils.getScopedAttribute(child, 1175 "attributeFormDefault"); 1176 if (def == null || def.equals("unqualified")) 1177 { 1178 attributeName = Utils.findQName("", attributeName.getLocalPart()); 1180 } 1181 } 1182 } 1183 else 1184 { 1185 attributeName = attributeType; 1186 } 1187 1188 TypeEntry type = symbolTable.getTypeEntry(attributeType, 1190 forElement.value); 1191 1192 if (type != null && attributeName != null) 1195 { 1196 v.add(type); 1197 v.add(attributeName); 1198 } 1199 } 1200 } 1201 return v; 1202 } 1203 1204 private static String schemaTypes[] = { 1206 "string", 1207 "normalizedString", 1208 "token", 1209 "byte", 1210 "unsignedByte", 1211 "base64Binary", 1212 "hexBinary", 1213 "integer", 1214 "positiveInteger", 1215 "negativeInteger", 1216 "nonNegativeInteger", 1217 "nonPositiveInteger", 1218 "int", 1219 "unsignedInt", 1220 "long", 1221 "unsignedLong", 1222 "short", 1223 "unsignedShort", 1224 "decimal", 1225 "float", 1226 "double", 1227 "boolean", 1228 "time", 1229 "dateTime", 1230 "duration", 1231 "date", 1232 "gMonth", 1233 "gYear", 1234 "gYearMonth", 1235 "gDay", 1236 "gMonthDay", 1237 "Name", 1238 "QName", 1239 "NCName", 1240 "anyURI", 1241 "language", 1242 "ID", 1243 "IDREF", 1244 "IDREFS", 1245 "ENTITY", 1246 "ENTITIES", 1247 "NOTATION", 1248 "NMTOKEN", 1249 "NMTOKENS" 1250 }; 1251 1252 private static final Set schemaTypeSet = new HashSet (Arrays.asList(schemaTypes)); 1253 1254 1257 private static boolean isSimpleSchemaType(String s) 1258 { 1259 if (s == null) 1260 return false; 1261 1262 return schemaTypeSet.contains(s); 1263 } 1264 1265 1268 public static boolean isSimpleSchemaType(QName qname) 1269 { 1270 if (qname == null || 1271 !Constants.isSchemaXSD(qname.getNamespaceURI())) 1272 { 1273 return false; 1274 } 1275 return isSimpleSchemaType(qname.getLocalPart()); 1276 } 1277} 1278 | Popular Tags |