Changeset 1183 for trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/CustomXmlDataStoragePart.java
- Timestamp:
- 08/09/10 15:56:17 (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/CustomXmlDataStoragePart.java
r1166 r1183 291 291 xpathBase = xpath; 292 292 } 293 294 // Drop any trailing position 295 if (xpathBase.endsWith("]")) 296 xpathBase = xpathBase.substring(0, xpathBase.lastIndexOf("[")); 297 293 298 log.debug("Repeat: using xpath: " + xpath); 294 299 NamespaceContext nsContext = new NamespacePrefixMappings(); … … 364 369 log.debug("existing xpath: " + thisXPath); 365 370 366 // The tricky part 371 /* The tricky part: replace path segment 372 * 373 * For xpathBase=/invoice[1]/items 374 * 375 * eg1 376 * 377 /invoice[1]/items/item[1]/name becomes 378 /invoice[1]/items/ *[n]/name 379 380 * eg2 381 * 382 /invoice[1]/items[1]/item[1]/name becomes 383 /invoice[1]/items / *[n]/name 384 */ 367 385 if (thisXPath.startsWith(xpathBase)) { 368 386 log.debug("xpathBase: " + xpathBase); 369 int beginIndex = thisXPath.indexOf("/", xpathBase.length()+1 ); // +1 for good measure 370 String newPath = xpathBase + "/*[" + (i+1) + "]/" + thisXPath.substring(beginIndex+1); 387 int beginIndex = thisXPath.indexOf("/", xpathBase.length()+1 ); // +1 for good measure 388 int endIndex = thisXPath.indexOf("/", beginIndex+1 ); 389 if (endIndex<0) endIndex = beginIndex; 390 391 String newPath = xpathBase + "/*[" + (i+1) + "]/" + thisXPath.substring(endIndex+1); 392 371 393 log.debug("newPath: " + newPath); 372 394 binding.setXpath(newPath);
Note: See TracChangeset
for help on using the changeset viewer.
