Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.opendope.conditions;
  
  import static org.docx4j.model.datastorage.XPathEnhancerParser.enhanceXPath;
  
  import java.util.List;
  import java.util.Map;
  
 

Java class for anonymous complex type.

The following schema fragment specifies the expected content contained within this class.

 <complexType>
   <complexContent>
     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
     </restriction>
   </complexContent>
 </complexType>
 
 
 @XmlType(name = "")
 @XmlRootElement(name = "xpathref")
 public class Xpathref implements Evaluable {
 
 	private static Logger log = LoggerFactory.getLogger(Xpathref.class);
 	
     @XmlAttribute(required = true)
     @XmlSchemaType(name = "NCName")
     protected String id;

    
Gets the value of the id property.

Returns:
possible object is
 
     public String getId() {
         return ;
     }

    
Sets the value of the id property.

Parameters:
value allowed object is
 
     public void setId(String value) {
         this. = value;
     }
 
 	public boolean evaluate(WordprocessingMLPackage pkg
 			Map<StringCustomXmlPartcustomXmlDataStorageParts,
 			Conditions conditions,
 			org.opendope.xpaths.Xpaths xPaths) {
 		
 		org.opendope.xpaths.Xpaths.Xpath xpath = XPathsPart.getXPathById(xPaths);	
 		
 		String val = BindingHandler.xpathGetString(pkg,
 				customXmlDataStoragePartsxpath.getDataBinding()
 						.getXpath(), xpath.getDataBinding()
 
 		return Boolean.parseBoolean(val);		
 		
     }
     
 	public void listXPathsList<org.opendope.xpaths.Xpaths.XpaththeList
			Conditions conditions,
		org.opendope.xpaths.Xpaths.Xpath xpath = XPathsPart.getXPathById(xPaths);	
    	theList.add(xpath);
	}

Map the IDs used in this condition to new values; useful for merging ConditionParts.

Parameters:
xpathIdMap
conditionIdMap
Since:
3.0.0
	public void mapIds(Map<StringStringxpathIdMapMap<StringStringconditionIdMap) {
		if (xpathIdMap==nullreturn;
		String newId = xpathIdMap.get(getId());
		if (newId!=null) {
			setId(newId);
		}
	}
	public String toString(Conditions conditions,
		org.opendope.xpaths.Xpaths.Xpath xpath = XPathsPart.getXPathById(xPaths);	
		return xpath.getDataBinding().getXpath(); 	
	}
	public Condition repeat(String xpathBase,
			int index,
			Conditions conditions,
		// this Xpathref is a clone already, 
		// but it points to the original xpathObj
		org.opendope.xpaths.Xpaths.Xpath xpathObj = XPathsPart.getXPathById(xPaths);	
		String thisXPath = xpathObj.getDataBinding().getXpath();
		if (thisXPath.trim().startsWith("count") ) {
			// we are trying to count rows of the repeat eg
			// eg xpath="count(/oda:answers/oda:repeat[@qref='r1_OE']/oda:row[1]/oda:repeat[@qref='r2_d4']/oda:row)&lt;=7"
			// or xpath="count(/oda:answers/oda:repeat[@qref='r1_OE']/oda:row)=999"
			// We want to enhance EXCEPT for the deepest repeat.
			int pos = thisXPath.indexOf(xpathBase) + xpathBase.length();
			if (thisXPath.substring(pos).contains("oda:repeat")) {
				// There are deeper repeats in thisXPath than xpathBase,
				// so enhance ..
				// NB this code is currently specific to oda:answers XML
else {
				..println("retaining: " + thisXPath);
				return null// ?
			}
		final String newPath = enhanceXPath(xpathBaseindex + 1, thisXPath);
		..println("newPath: " + newPath);
		if (.isDebugEnabled() && !thisXPath.equals(newPath)) {
			.debug("xpath prefix enhanced " + thisXPath + " to " + newPath);
		}
		// Clone the xpath
				newPathxpathObjindex);
		// point this at it
		this. = newXPathObj.getId();		
		return null;
	}	
			String newPathorg.opendope.xpaths.Xpaths.Xpath xpathObjint index) {
		org.opendope.xpaths.Xpaths.Xpath newXPathObj = XmlUtils
				.deepCopy(xpathObj);
		String newXPathId = newXPathObj.getId() + "_" + index;
		newXPathObj.setId(newXPathId);
		newXPathObj.getDataBinding().setXpath(newPath);
		xPaths.getXpath().add(newXPathObj);
		return newXPathObj;
	}
New to GrepCode? Check out our FAQ X