Example #1
0
 public static void fixNamespaceForXsiType(XmlObject content, Map<?, ?> namespaces) {
   final XmlCursor cursor = content.newCursor();
   while (cursor.hasNextToken()) {
     if (cursor.toNextToken().isStart()) {
       final String xsiType = cursor.getAttributeText(W3CConstants.QN_XSI_TYPE);
       if (xsiType != null) {
         final String[] toks = xsiType.split(":");
         if (toks.length > 1) {
           String prefix = toks[0];
           String localName = toks[1];
           String namespace = (String) namespaces.get(prefix);
           if (Strings.isNullOrEmpty(namespace)) {
             namespace = CodingRepository.getInstance().getNamespaceFor(prefix);
           }
           if (StringHelper.isNotEmpty(namespace)) {
             cursor.setAttributeText(
                 W3CConstants.QN_XSI_TYPE,
                 Joiner.on(Constants.COLON_CHAR)
                     .join(
                         XmlHelper.getPrefixForNamespace(content, (String) namespaces.get(prefix)),
                         localName));
           }
         }
       }
     }
   }
   cursor.dispose();
 }
Example #2
0
 /**
  * Check if namespace is not null and equals GML 3.1.1 or GML 3.2.1 namespace.
  *
  * @param namespaceToCheck Namespace to check
  * @param namespaces GML namespaces
  * @return <code>true</code>, if namespaceToCheck is a GML namespace
  */
 private static boolean isNotNullAndEqualsNSs(
     String namespaceToCheck, Collection<String> namespaces) {
   if (StringHelper.isNotEmpty(namespaceToCheck)) {
     return namespaces.contains(namespaceToCheck);
   }
   return false;
 }
Example #3
0
 @Override
 public boolean shouldPass(final XmlValidationError xve) {
   if (xve.getObjectLocation() != null
       && xve.getObjectLocation().getDomNode() != null
       && xve.getObjectLocation().getDomNode().getFirstChild() != null) {
     String nodeName = xve.getObjectLocation().getDomNode().getFirstChild().getNodeName();
     return StringHelper.isNotEmpty(nodeName) && nodeName.contains(GET_DATA_AVAILABILITY);
   }
   return false;
 }
Example #4
0
 /**
  * Check if attribute or node namespace is a GML id.
  *
  * @param attr Attribure to check
  * @param nodeNamespace Node namespace
  * @return <code>true</code>, if attribute or node is a GML id
  */
 private static boolean checkAttributeForGmlId(Attr attr, String nodeNamespace) {
   final String attrNamespace = attr.getNamespaceURI();
   if (GmlConstants.GML_ID_WITH_PREFIX.equals(attr.getName())) {
     return true;
   } else {
     if (StringHelper.isNotEmpty(attrNamespace)) {
       return isNotNullAndEqualsNSs(attrNamespace, getGmlNSs());
     } else {
       return isNotNullAndEqualsNSs(nodeNamespace, getGmlNSs());
     }
   }
 }
 public void render(StringBuffer buffer, String alias, Map enabledFilters) {
   if (filterNames != null && filterNames.length > 0) {
     for (int i = 0, max = filterNames.length; i < max; i++) {
       if (enabledFilters.containsKey(filterNames[i])) {
         final String condition = filterConditions[i];
         if (StringHelper.isNotEmpty(condition)) {
           buffer
               .append(" and ")
               .append(StringHelper.replace(condition, FilterImpl.MARKER, alias));
         }
       }
     }
   }
 }