@Override public void attributeDecl(String elementName, String attributeName, String attributeType, String[] enumeration, short attributeUse, String defaultValue) throws SAXException { if (isVerbose) { System.out.println("attributeDecl: elementName: " + elementName + " attributeName: " + attributeName + " attributeType: " + attributeType + " enumeration: " + enumeration + " attributeUse: " + attributeUse); } /** * Don't add the system attribute id otherwise we have problems with the mixed content. */ if (!attributeType.equals("ID")) { final MetadataElement element = new MetadataElement(); element.setName(attributeName); element.setIsAttribute(true); element.setType("xsd:string"); metadata.addClassElement(elementName, element); } }
if (item.getNamespace().equals(elItems[0]) && item.getName().equals(elItems[1])) { for (MetadataElement element : item.getElements()) { if (!isDataType(element.getType(), metadata)) { if (!classList.contains(element.getType())) { classList.add(element.getType()); traverseClasses(metadata, classList, element.getType()); if (!isDataType(element.getType(), metadata)) { if (!classList.contains(element.getRef())) { classList.add(element.getRef()); traverseClasses(metadata, classList, element.getRef()); if (item.getNamespace().equals(elItems[0]) && item.getName().equals(elItems[1])) { for (MetadataElement element : item.getElements()) { if (!isDataType(element.getType(), metadata)) { if (!classList.contains(element.getType())) { classList.add(element.getType()); traverseClasses(metadata, classList, element.getType()); if (!isDataType(element.getType(), metadata)) { if (!classList.contains(element.getRef())) { classList.add(element.getRef()); traverseClasses(metadata, classList, element.getRef());
@Override public void mixedElement(String elementName) throws SAXException { if (isVerbose) { System.out.println("mixedElement: elementName: " + elementName); } final MetadataElement element = new MetadataElement(); element.setName(elementName); element.setType(elementName); metadata.addClassElement(currentContentModel, element); }
@Override public void endModelGroup(short occurence) throws SAXException { if (isVerbose) { System.out.println("endModelGroup: occurence: " + occurence); } final Map<String, Short> modelGroupElements = modelGroupStack.get(modelGroupStack.size() - 1); for (Iterator it = modelGroupElements.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); String elementName = (String) entry.getKey(); Short elementOccurence = (Short) entry.getValue(); boolean isUnbounded = false; if (occurence == DTDEventListener.OCCURENCE_ZERO_OR_MORE || occurence == DTDEventListener.OCCURENCE_ONE_OR_MORE || elementOccurence == DTDEventListener.OCCURENCE_ZERO_OR_MORE || elementOccurence == DTDEventListener.OCCURENCE_ONE_OR_MORE) { isUnbounded = true; } final MetadataElement element = new MetadataElement(); element.setName(elementName); element.setType(elementName); if (isUnbounded) { element.setMaxOccurs("unbounded"); } metadata.addClassElement(currentContentModel, element); } modelGroupStack.remove(modelGroupElements); }
elName.setValue(element.getName()); childElement.setAttributeNode(elName); elType.setValue(element.getType()); childElement.setAttributeNode(elType); if (element.getIsAttribute() == true) { final Attr elAttribute = doc.createAttribute("attribute"); elAttribute.setValue(Boolean.toString(element.getIsAttribute())); childElement.setAttributeNode(elAttribute); if (element.getDefaultValue() != null) { final Attr elAttribute = doc.createAttribute("default"); elAttribute.setValue(element.getDefaultValue()); childElement.setAttributeNode(elAttribute); if (element.getFixedValue() != null) { final Attr elAttribute = doc.createAttribute("fixed"); elAttribute.setValue(element.getFixedValue()); childElement.setAttributeNode(elAttribute); if (element.getUse() != null) { final Attr elAttribute = doc.createAttribute("use"); elAttribute.setValue(element.getUse()); childElement.setAttributeNode(elAttribute); if (element.getMaxOccurs() != null) { final Attr elMaxOccurs = doc.createAttribute("maxOccurs"); elMaxOccurs.setValue(element.getMaxOccurs());
classElement.setType(getNamespaceValue(classElement.getType())); if (classElement.getMaxOccurs() != null && !classElement.getMaxOccurs().equals("1")) { classElement.setMaxOccurs("unbounded"); if (element.getName().equals(classElement.getName()) && !classElement.getIsAttribute()) { element.setMaxOccurs("unbounded"); return;
sb.append(NEWLINE); for (MetadataElement element : item.getElements()) { sb.append(" Element : " + element.getName()); sb.append(NEWLINE); sb.append(" Type : " + element.getType()); sb.append(NEWLINE); sb.append(" MinOccurs: " + element.getMinOccurs()); sb.append(NEWLINE); sb.append(" MaxOccurs: " + element.getMaxOccurs()); sb.append(NEWLINE); sb.append(" IsAttr : " + element.getIsAttribute()); sb.append(NEWLINE); sb.append(NEWLINE); sb.append(" Ref : " + element.getRef()); sb.append(NEWLINE); sb.append(NEWLINE); for (MetadataElement element : item.getElements()) { sb.append(" Element : " + element.getName()); sb.append(NEWLINE); sb.append(" Type : " + element.getType()); sb.append(NEWLINE); sb.append(" MinOccurs: " + element.getMinOccurs()); sb.append(NEWLINE); sb.append(" MaxOccurs: " + element.getMaxOccurs()); sb.append(NEWLINE); sb.append(" IsAttr : " + element.getIsAttribute()); sb.append(NEWLINE);
final MetadataElement refElement = new MetadataElement(element); refElement.setIsRef(true); final String maxOccurs = MetadataUtil.getAttributeValue(p, "maxOccurs"); if (maxOccurs != null && !maxOccurs.equals("1")) { refElement.setMaxOccurs("unbounded");
/** * Adds a new reference to the specific group element class. If no group element class is found, then a new group * element class. will be created. * * @param groupName * the group class name of * @param groupReference * the new reference to be added. */ public void addGroupReference(final String groupName, final MetadataElement groupReference) { groupReference.setRef(getNamespaceValue(groupReference.getRef())); for (MetadataItem item : groupList) { if (item.getName().equals(groupName) && item.getNamespace().equals(getCurrentNamespace())) { item.getReferences().add(groupReference); return; } } final MetadataItem newItem = new MetadataItem(groupName); newItem.getReferences().add(groupReference); newItem.setNamespace(getCurrentNamespace()); newItem.setSchemaName(getCurrentSchmema()); newItem.setPackageApi(getCurrentPackageApi()); newItem.setPackageImpl(getCurrentPackageImpl()); groupList.add(newItem); }
public boolean filter(final Metadata metadata, final TreeWalker walker) { final Node parent = walker.getCurrentNode(); final Element element = (Element) parent; if (XsdElementEnum.attributeGroup.isTagNameEqual(element.getTagName())) { final Node refNode = element.getAttributes().getNamedItem("ref"); if (refNode != null) { final MetadataElement refElement = new MetadataElement(element); refElement.setIsRef(true); final Node parentNodeWithName = MetadataUtil.getNextParentNodeWithAttr(parent.getParentNode(), "name"); if (parentNodeWithName != null) { final Element parentElementWithName = (Element) parentNodeWithName; final String groupOrClassName = MetadataUtil.getAttributeValue(parentElementWithName, "name"); if (XsdElementEnum.attributeGroup.isTagNameEqual(parentElementWithName.getTagName())) { metadata.addGroupReference(groupOrClassName, refElement); return true; } else { metadata.addClassReference(groupOrClassName, refElement); return true; } } } } return false; } }
private void preResolveDataTypeImpl(final MetadataItem metadataClass) { for (MetadataElement element : metadataClass.getElements()) { for (MetadataItem dataType : getDataTypeList()) { final String str = dataType.getNamespace() + ":" + dataType.getName(); if (str.equals(element.getType())) { element.setType(dataType.getMappedTo()); } } /** * replace the xs namespace with xsd, ddJavaAll xslt likes this more */ element.setType(element.getType().replace("xs:", "xsd:")); /** * Set default xsd namespace */ if (!element.getType().contains(":") && XsdDatatypeEnum.integer.isDataType("xsd:" + element.getType())) element.setType("xsd:" + element.getType()); /** * Check java keywords */ // if (JavaKeywordsEnum.abstract_keyword.isJavaKeyword(element.getName())) // { // element.setName("_" + element.getName()); // } } }
public String getFqnClass(final MetadataElement element) { final String namespace = splitElementType(element.getType())[0]; final String localname = splitElementType(element.getType())[1]; // search in all enumeration for (final MetadataEnum metadataEnum : metadata.getEnumList()) { if (metadataEnum.getName().equals(localname) && metadataEnum.getNamespace().equals(namespace)) { return metadataEnum.getPackageApi() + "." + getPascalizeCase(metadataEnum.getName()); } } // search in all classes for (final MetadataItem metadataClass : metadata.getClassList()) { if (metadataClass.getName().equals(localname) && metadataClass.getNamespace().equals(namespace)) { return metadataClass.getPackageApi() + "." + getPascalizeCase(metadataClass.getName()); } } return null; }
elName.setValue(element.getName()); childElement.setAttributeNode(elName); elType.setValue(element.getType()); childElement.setAttributeNode(elType); if (element.getIsAttribute() == true) { final Attr elAttribute = doc.createAttribute("attribute"); elAttribute.setValue(Boolean.toString(element.getIsAttribute())); childElement.setAttributeNode(elAttribute); if (element.getDefaultValue() != null) { final Attr elAttribute = doc.createAttribute("default"); elAttribute.setValue(element.getDefaultValue()); childElement.setAttributeNode(elAttribute); if (element.getFixedValue() != null) { final Attr elAttribute = doc.createAttribute("fixed"); elAttribute.setValue(element.getFixedValue()); childElement.setAttributeNode(elAttribute); if (element.getUse() != null) { final Attr elAttribute = doc.createAttribute("use"); elAttribute.setValue(element.getUse()); childElement.setAttributeNode(elAttribute); if (element.getMaxOccurs() != null) { final Attr elMaxOccurs = doc.createAttribute("maxOccurs"); elMaxOccurs.setValue(element.getMaxOccurs());
@Override public void endModelGroup(short occurence) throws SAXException { if (isVerbose) { System.out.println("endModelGroup: occurence: " + occurence); } final Map<String, Short> modelGroupElements = modelGroupStack.get(modelGroupStack.size() - 1); for (Iterator it = modelGroupElements.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); String elementName = (String) entry.getKey(); Short elementOccurence = (Short) entry.getValue(); boolean isUnbounded = false; if (occurence == DTDEventListener.OCCURENCE_ZERO_OR_MORE || occurence == DTDEventListener.OCCURENCE_ONE_OR_MORE || elementOccurence == DTDEventListener.OCCURENCE_ZERO_OR_MORE || elementOccurence == DTDEventListener.OCCURENCE_ONE_OR_MORE) { isUnbounded = true; } final MetadataElement element = new MetadataElement(); element.setName(elementName); element.setType(elementName); if (isUnbounded) { element.setMaxOccurs("unbounded"); } metadata.addClassElement(currentContentModel, element); } modelGroupStack.remove(modelGroupElements); }
classElement.setType(getNamespaceValue(classElement.getType())); if (classElement.getMaxOccurs() != null && !classElement.getMaxOccurs().equals("1")) { classElement.setMaxOccurs("unbounded"); if (element.getName().equals(classElement.getName()) && !classElement.getIsAttribute()) { element.setMaxOccurs("unbounded"); return;
sb.append(NEWLINE); for (MetadataElement element : item.getElements()) { sb.append(" Element : " + element.getName()); sb.append(NEWLINE); sb.append(" Type : " + element.getType()); sb.append(NEWLINE); sb.append(" MinOccurs: " + element.getMinOccurs()); sb.append(NEWLINE); sb.append(" MaxOccurs: " + element.getMaxOccurs()); sb.append(NEWLINE); sb.append(" IsAttr : " + element.getIsAttribute()); sb.append(NEWLINE); sb.append(NEWLINE); sb.append(" Ref : " + element.getRef()); sb.append(NEWLINE); sb.append(NEWLINE); for (MetadataElement element : item.getElements()) { sb.append(" Element : " + element.getName()); sb.append(NEWLINE); sb.append(" Type : " + element.getType()); sb.append(NEWLINE); sb.append(" MinOccurs: " + element.getMinOccurs()); sb.append(NEWLINE); sb.append(" MaxOccurs: " + element.getMaxOccurs()); sb.append(NEWLINE); sb.append(" IsAttr : " + element.getIsAttribute()); sb.append(NEWLINE);
@Override public void mixedElement(String elementName) throws SAXException { if (isVerbose) { System.out.println("mixedElement: elementName: " + elementName); } final MetadataElement element = new MetadataElement(); element.setName(elementName); element.setType(elementName); metadata.addClassElement(currentContentModel, element); }
final MetadataElement refElement = new MetadataElement(element); refElement.setIsRef(true); final String maxOccurs = MetadataUtil.getAttributeValue(p, "maxOccurs"); if (maxOccurs != null && !maxOccurs.equals("1")) { refElement.setMaxOccurs("unbounded");
/** * Adds a new reference to the specific element class. If no element class is found, then a new element class. will * be created. * * @param className * the class name * @param classReference * the new reference to be added. */ public void addClassReference(final String className, final MetadataElement classReference) { classReference.setRef(getNamespaceValue(classReference.getRef())); for (MetadataItem item : classList) { if (item.getName().equals(className) && item.getNamespace().equals(getCurrentNamespace()) && item.getPackageApi().equals(getCurrentPackageApi())) { item.getReferences().add(classReference); return; } } final MetadataItem newItem = new MetadataItem(className); newItem.getReferences().add(classReference); newItem.setNamespace(getCurrentNamespace()); newItem.setSchemaName(getCurrentSchmema()); newItem.setPackageApi(getCurrentPackageApi()); newItem.setPackageImpl(getCurrentPackageImpl()); classList.add(newItem); }
public boolean filter(final Metadata metadata, final TreeWalker walker) { final Node parent = walker.getCurrentNode(); final Element element = (Element) parent; if (XsdElementEnum.attributeGroup.isTagNameEqual(element.getTagName())) { final Node refNode = element.getAttributes().getNamedItem("ref"); if (refNode != null) { final MetadataElement refElement = new MetadataElement(element); refElement.setIsRef(true); final Node parentNodeWithName = MetadataUtil.getNextParentNodeWithAttr(parent.getParentNode(), "name"); if (parentNodeWithName != null) { final Element parentElementWithName = (Element) parentNodeWithName; final String groupOrClassName = MetadataUtil.getAttributeValue(parentElementWithName, "name"); if (XsdElementEnum.attributeGroup.isTagNameEqual(parentElementWithName.getTagName())) { metadata.addGroupReference(groupOrClassName, refElement); return true; } else { metadata.addClassReference(groupOrClassName, refElement); return true; } } } } return false; } }