@Test public void refAndName() { attributes.addAttribute("", "ref", "ref", "string", "test:another-element"); attributes.addAttribute("", "name", "name", "string", "some-name"); try { handler.startElement(NAMESPACE_URI, "element", attributes); Assert.fail(); } catch (SAXException e) { Assert.assertEquals( "Schema element declaration cannot have both 'ref' and 'name' " + "attributes (ref=\"test:another-element\", name=\"some-name\")", e.getMessage()); } }
public void startElement(String namespaceURI, String localName, Attributes atts) throws SAXException { String abstracT1 = atts.getValue("", "abstracT"); if (abstracT1 == null) { abstracT1 = atts.getValue(namespaceURI, "abstracT"); } if ((abstracT1 == null) || "".equalsIgnoreCase(abstracT1)) { this.abstracT = false; } else { this.abstracT = Boolean.getBoolean(abstracT1); } String block1 = atts.getValue("", "block"); if (block1 == null) { block1 = atts.getValue(namespaceURI, "block"); } this.block = ComplexTypeHandler.findBlock(block1); defaulT = atts.getValue("", "default"); if (defaulT == null) { defaulT = atts.getValue(namespaceURI, "default"); } String finaL1 = atts.getValue("", "final"); if (finaL1 == null) { finaL1 = atts.getValue(namespaceURI, "final"); } this.finaL = ComplexTypeHandler.findFinal(finaL1); fixed = atts.getValue("", "fixed"); if (fixed == null) { fixed = atts.getValue(namespaceURI, "fixed"); } String form1 = atts.getValue("", "form"); if (form1 == null) { form1 = atts.getValue(namespaceURI, "form"); } this.form = "qualified".equalsIgnoreCase(form1); id = atts.getValue("", "id"); if (id == null) { id = atts.getValue(namespaceURI, "id"); } String maxOccurs1 = atts.getValue("", "maxOccurs"); if (maxOccurs1 == null) { maxOccurs1 = atts.getValue(namespaceURI, "maxOccurs"); } if ((maxOccurs1 != null) && !"".equalsIgnoreCase(maxOccurs1)) { if ("unbounded".equalsIgnoreCase(maxOccurs1)) { this.maxOccurs = ElementGrouping.UNBOUNDED; } else { this.maxOccurs = Integer.parseInt(maxOccurs1); } } else { this.maxOccurs = 1; } String minOccurs1 = atts.getValue("", "minOccurs"); if (minOccurs1 == null) { minOccurs1 = atts.getValue(namespaceURI, "minOccurs"); } if ((minOccurs1 != null) && !"".equalsIgnoreCase(minOccurs1)) { this.minOccurs = Integer.parseInt(minOccurs1); } else { this.minOccurs = 1; } name = atts.getValue("", "name"); if (name == null) { name = atts.getValue(namespaceURI, "name"); } String nillable1 = atts.getValue("", "nillable"); if (nillable1 == null) { nillable1 = atts.getValue(namespaceURI, "nillable"); } if ((nillable1 == null) || "".equalsIgnoreCase(nillable1)) { this.nillable = false; } else { this.nillable = Boolean.valueOf(nillable1).booleanValue(); } ref = atts.getValue("", "ref"); if (ref == null) { ref = atts.getValue(namespaceURI, "ref"); } substitutionGroup = atts.getValue("", "substitutionGroup"); if (substitutionGroup == null) { substitutionGroup = atts.getValue(namespaceURI, "substitutionGroup"); } type = atts.getValue("", "type"); if (type == null) { type = atts.getValue(namespaceURI, "type"); } if (ref != null && !ref.isEmpty()) { if (name != null && !name.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'name' attributes (ref=\"%s\", name=\"%s\")", ref, name)); } if (type != null && !type.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'type' attributes (ref=\"%s\", type=\"%s\")", ref, type)); } name = type = ref; } }
ElementTypeHandler extends ElementGroupingHandler { public void startElement(String namespaceURI, String localName, Attributes atts) throws SAXException { String abstracT1 = atts.getValue("", "abstracT"); if (abstracT1 == null) { abstracT1 = atts.getValue(namespaceURI, "abstracT"); } if ((abstracT1 == null) || "".equalsIgnoreCase(abstracT1)) { this.abstracT = false; } else { this.abstracT = Boolean.getBoolean(abstracT1); } String block1 = atts.getValue("", "block"); if (block1 == null) { block1 = atts.getValue(namespaceURI, "block"); } this.block = ComplexTypeHandler.findBlock(block1); defaulT = atts.getValue("", "default"); if (defaulT == null) { defaulT = atts.getValue(namespaceURI, "default"); } String finaL1 = atts.getValue("", "final"); if (finaL1 == null) { finaL1 = atts.getValue(namespaceURI, "final"); } this.finaL = ComplexTypeHandler.findFinal(finaL1); fixed = atts.getValue("", "fixed"); if (fixed == null) { fixed = atts.getValue(namespaceURI, "fixed"); } String form1 = atts.getValue("", "form"); if (form1 == null) { form1 = atts.getValue(namespaceURI, "form"); } this.form = "qualified".equalsIgnoreCase(form1); id = atts.getValue("", "id"); if (id == null) { id = atts.getValue(namespaceURI, "id"); } String maxOccurs1 = atts.getValue("", "maxOccurs"); if (maxOccurs1 == null) { maxOccurs1 = atts.getValue(namespaceURI, "maxOccurs"); } if ((maxOccurs1 != null) && !"".equalsIgnoreCase(maxOccurs1)) { if ("unbounded".equalsIgnoreCase(maxOccurs1)) { this.maxOccurs = ElementGrouping.UNBOUNDED; } else { this.maxOccurs = Integer.parseInt(maxOccurs1); } } else { this.maxOccurs = 1; } String minOccurs1 = atts.getValue("", "minOccurs"); if (minOccurs1 == null) { minOccurs1 = atts.getValue(namespaceURI, "minOccurs"); } if ((minOccurs1 != null) && !"".equalsIgnoreCase(minOccurs1)) { this.minOccurs = Integer.parseInt(minOccurs1); } else { this.minOccurs = 1; } name = atts.getValue("", "name"); if (name == null) { name = atts.getValue(namespaceURI, "name"); } String nillable1 = atts.getValue("", "nillable"); if (nillable1 == null) { nillable1 = atts.getValue(namespaceURI, "nillable"); } if ((nillable1 == null) || "".equalsIgnoreCase(nillable1)) { this.nillable = false; } else { this.nillable = Boolean.valueOf(nillable1).booleanValue(); } ref = atts.getValue("", "ref"); if (ref == null) { ref = atts.getValue(namespaceURI, "ref"); } substitutionGroup = atts.getValue("", "substitutionGroup"); if (substitutionGroup == null) { substitutionGroup = atts.getValue(namespaceURI, "substitutionGroup"); } type = atts.getValue("", "type"); if (type == null) { type = atts.getValue(namespaceURI, "type"); } if (ref != null && !ref.isEmpty()) { if (name != null && !name.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'name' attributes (ref=\"%s\", name=\"%s\")", ref, name)); } if (type != null && !type.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'type' attributes (ref=\"%s\", type=\"%s\")", ref, type)); } name = type = ref; } } }
ElementTypeHandler extends ElementGroupingHandler { public void startElement(String namespaceURI, String localName, Attributes atts) throws SAXException { String abstracT1 = atts.getValue("", "abstracT"); if (abstracT1 == null) { abstracT1 = atts.getValue(namespaceURI, "abstracT"); } if ((abstracT1 == null) || "".equalsIgnoreCase(abstracT1)) { this.abstracT = false; } else { this.abstracT = Boolean.getBoolean(abstracT1); } String block1 = atts.getValue("", "block"); if (block1 == null) { block1 = atts.getValue(namespaceURI, "block"); } this.block = ComplexTypeHandler.findBlock(block1); defaulT = atts.getValue("", "default"); if (defaulT == null) { defaulT = atts.getValue(namespaceURI, "default"); } String finaL1 = atts.getValue("", "final"); if (finaL1 == null) { finaL1 = atts.getValue(namespaceURI, "final"); } this.finaL = ComplexTypeHandler.findFinal(finaL1); fixed = atts.getValue("", "fixed"); if (fixed == null) { fixed = atts.getValue(namespaceURI, "fixed"); } String form1 = atts.getValue("", "form"); if (form1 == null) { form1 = atts.getValue(namespaceURI, "form"); } this.form = "qualified".equalsIgnoreCase(form1); id = atts.getValue("", "id"); if (id == null) { id = atts.getValue(namespaceURI, "id"); } String maxOccurs1 = atts.getValue("", "maxOccurs"); if (maxOccurs1 == null) { maxOccurs1 = atts.getValue(namespaceURI, "maxOccurs"); } if ((maxOccurs1 != null) && !"".equalsIgnoreCase(maxOccurs1)) { if ("unbounded".equalsIgnoreCase(maxOccurs1)) { this.maxOccurs = ElementGrouping.UNBOUNDED; } else { this.maxOccurs = Integer.parseInt(maxOccurs1); } } else { this.maxOccurs = 1; } String minOccurs1 = atts.getValue("", "minOccurs"); if (minOccurs1 == null) { minOccurs1 = atts.getValue(namespaceURI, "minOccurs"); } if ((minOccurs1 != null) && !"".equalsIgnoreCase(minOccurs1)) { this.minOccurs = Integer.parseInt(minOccurs1); } else { this.minOccurs = 1; } name = atts.getValue("", "name"); if (name == null) { name = atts.getValue(namespaceURI, "name"); } String nillable1 = atts.getValue("", "nillable"); if (nillable1 == null) { nillable1 = atts.getValue(namespaceURI, "nillable"); } if ((nillable1 == null) || "".equalsIgnoreCase(nillable1)) { this.nillable = false; } else { this.nillable = Boolean.valueOf(nillable1).booleanValue(); } ref = atts.getValue("", "ref"); if (ref == null) { ref = atts.getValue(namespaceURI, "ref"); } substitutionGroup = atts.getValue("", "substitutionGroup"); if (substitutionGroup == null) { substitutionGroup = atts.getValue(namespaceURI, "substitutionGroup"); } type = atts.getValue("", "type"); if (type == null) { type = atts.getValue(namespaceURI, "type"); } if (ref != null && !ref.isEmpty()) { if (name != null && !name.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'name' attributes (ref=\"%s\", name=\"%s\")", ref, name)); } if (type != null && !type.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'type' attributes (ref=\"%s\", type=\"%s\")", ref, type)); } name = type = ref; } }  }
ElementTypeHandler extends ElementGroupingHandler { public void startElement(String namespaceURI, String localName, Attributes atts) throws SAXException { String abstracT1 = atts.getValue("", "abstracT"); if (abstracT1 == null) { abstracT1 = atts.getValue(namespaceURI, "abstracT"); } if ((abstracT1 == null) || "".equalsIgnoreCase(abstracT1)) { this.abstracT = false; } else { this.abstracT = Boolean.getBoolean(abstracT1); } String block1 = atts.getValue("", "block"); if (block1 == null) { block1 = atts.getValue(namespaceURI, "block"); } this.block = ComplexTypeHandler.findBlock(block1); defaulT = atts.getValue("", "default"); if (defaulT == null) { defaulT = atts.getValue(namespaceURI, "default"); } String finaL1 = atts.getValue("", "final"); if (finaL1 == null) { finaL1 = atts.getValue(namespaceURI, "final"); } this.finaL = ComplexTypeHandler.findFinal(finaL1); fixed = atts.getValue("", "fixed"); if (fixed == null) { fixed = atts.getValue(namespaceURI, "fixed"); } String form1 = atts.getValue("", "form"); if (form1 == null) { form1 = atts.getValue(namespaceURI, "form"); } this.form = "qualified".equalsIgnoreCase(form1); id = atts.getValue("", "id"); if (id == null) { id = atts.getValue(namespaceURI, "id"); } String maxOccurs1 = atts.getValue("", "maxOccurs"); if (maxOccurs1 == null) { maxOccurs1 = atts.getValue(namespaceURI, "maxOccurs"); } if ((maxOccurs1 != null) && !"".equalsIgnoreCase(maxOccurs1)) { if ("unbounded".equalsIgnoreCase(maxOccurs1)) { this.maxOccurs = ElementGrouping.UNBOUNDED; } else { this.maxOccurs = Integer.parseInt(maxOccurs1); } } else { this.maxOccurs = 1; } String minOccurs1 = atts.getValue("", "minOccurs"); if (minOccurs1 == null) { minOccurs1 = atts.getValue(namespaceURI, "minOccurs"); } if ((minOccurs1 != null) && !"".equalsIgnoreCase(minOccurs1)) { this.minOccurs = Integer.parseInt(minOccurs1); } else { this.minOccurs = 1; } name = atts.getValue("", "name"); if (name == null) { name = atts.getValue(namespaceURI, "name"); } String nillable1 = atts.getValue("", "nillable"); if (nillable1 == null) { nillable1 = atts.getValue(namespaceURI, "nillable"); } if ((nillable1 == null) || "".equalsIgnoreCase(nillable1)) { this.nillable = false; } else { this.nillable = Boolean.valueOf(nillable1).booleanValue(); } ref = atts.getValue("", "ref"); if (ref == null) { ref = atts.getValue(namespaceURI, "ref"); } substitutionGroup = atts.getValue("", "substitutionGroup"); if (substitutionGroup == null) { substitutionGroup = atts.getValue(namespaceURI, "substitutionGroup"); } type = atts.getValue("", "type"); if (type == null) { type = atts.getValue(namespaceURI, "type"); } if (ref != null && !ref.isEmpty()) { if (name != null && !name.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'name' attributes (ref=\"%s\", name=\"%s\")", ref, name)); } if (type != null && !type.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'type' attributes (ref=\"%s\", type=\"%s\")", ref, type)); } name = type = ref; } }  @SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") int hashCode(); XSIElementHandler getHandler(String namespaceURI, String localName); void startElement(String namespaceURI, String localName, Attributes atts); String getLocalName(); String getName(); int getHandlerType(); void endElement(String namespaceURI, String localName); }
ElementTypeHandler extends ElementGroupingHandler { public void startElement(String namespaceURI, String localName, Attributes atts) throws SAXException { String abstracT1 = atts.getValue("", "abstracT"); if (abstracT1 == null) { abstracT1 = atts.getValue(namespaceURI, "abstracT"); } if ((abstracT1 == null) || "".equalsIgnoreCase(abstracT1)) { this.abstracT = false; } else { this.abstracT = Boolean.getBoolean(abstracT1); } String block1 = atts.getValue("", "block"); if (block1 == null) { block1 = atts.getValue(namespaceURI, "block"); } this.block = ComplexTypeHandler.findBlock(block1); defaulT = atts.getValue("", "default"); if (defaulT == null) { defaulT = atts.getValue(namespaceURI, "default"); } String finaL1 = atts.getValue("", "final"); if (finaL1 == null) { finaL1 = atts.getValue(namespaceURI, "final"); } this.finaL = ComplexTypeHandler.findFinal(finaL1); fixed = atts.getValue("", "fixed"); if (fixed == null) { fixed = atts.getValue(namespaceURI, "fixed"); } String form1 = atts.getValue("", "form"); if (form1 == null) { form1 = atts.getValue(namespaceURI, "form"); } this.form = "qualified".equalsIgnoreCase(form1); id = atts.getValue("", "id"); if (id == null) { id = atts.getValue(namespaceURI, "id"); } String maxOccurs1 = atts.getValue("", "maxOccurs"); if (maxOccurs1 == null) { maxOccurs1 = atts.getValue(namespaceURI, "maxOccurs"); } if ((maxOccurs1 != null) && !"".equalsIgnoreCase(maxOccurs1)) { if ("unbounded".equalsIgnoreCase(maxOccurs1)) { this.maxOccurs = ElementGrouping.UNBOUNDED; } else { this.maxOccurs = Integer.parseInt(maxOccurs1); } } else { this.maxOccurs = 1; } String minOccurs1 = atts.getValue("", "minOccurs"); if (minOccurs1 == null) { minOccurs1 = atts.getValue(namespaceURI, "minOccurs"); } if ((minOccurs1 != null) && !"".equalsIgnoreCase(minOccurs1)) { this.minOccurs = Integer.parseInt(minOccurs1); } else { this.minOccurs = 1; } name = atts.getValue("", "name"); if (name == null) { name = atts.getValue(namespaceURI, "name"); } String nillable1 = atts.getValue("", "nillable"); if (nillable1 == null) { nillable1 = atts.getValue(namespaceURI, "nillable"); } if ((nillable1 == null) || "".equalsIgnoreCase(nillable1)) { this.nillable = false; } else { this.nillable = Boolean.valueOf(nillable1).booleanValue(); } ref = atts.getValue("", "ref"); if (ref == null) { ref = atts.getValue(namespaceURI, "ref"); } substitutionGroup = atts.getValue("", "substitutionGroup"); if (substitutionGroup == null) { substitutionGroup = atts.getValue(namespaceURI, "substitutionGroup"); } type = atts.getValue("", "type"); if (type == null) { type = atts.getValue(namespaceURI, "type"); } if (ref != null && !ref.isEmpty()) { if (name != null && !name.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'name' attributes (ref=\"%s\", name=\"%s\")", ref, name)); } if (type != null && !type.isEmpty()) { throw new SAXException( String.format( "Schema element declaration cannot have both " + "'ref' and 'type' attributes (ref=\"%s\", type=\"%s\")", ref, type)); } name = type = ref; } }  @SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") int hashCode(); XSIElementHandler getHandler(String namespaceURI, String localName); void startElement(String namespaceURI, String localName, Attributes atts); String getLocalName(); String getName(); int getHandlerType(); void endElement(String namespaceURI, String localName); static final String LOCALNAME; }