| 1 |
package ezvcard.io.scribe; |
| 2 |
|
| 3 |
import static ezvcard.util.TestUtils.assertParseWarnings; |
| 4 |
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; |
| 5 |
import static org.junit.Assert.assertEquals; |
| 6 |
import static org.junit.Assert.assertTrue; |
| 7 |
import static org.junit.Assert.fail; |
| 8 |
|
| 9 |
import java.util.List; |
| 10 |
import java.util.Map; |
| 11 |
|
| 12 |
import javax.xml.namespace.QName; |
| 13 |
|
| 14 |
import org.w3c.dom.Document; |
| 15 |
import org.w3c.dom.Element; |
| 16 |
import org.xml.sax.SAXException; |
| 17 |
|
| 18 |
import ezvcard.VCard; |
| 19 |
import ezvcard.VCardDataType; |
| 20 |
import ezvcard.VCardVersion; |
| 21 |
import ezvcard.io.CannotParseException; |
| 22 |
import ezvcard.io.ParseContext; |
| 23 |
import ezvcard.io.SkipMeException; |
| 24 |
import ezvcard.io.html.HCardElement; |
| 25 |
import ezvcard.io.json.JCardValue; |
| 26 |
import ezvcard.io.text.WriteContext; |
| 27 |
import ezvcard.parameter.VCardParameters; |
| 28 |
import ezvcard.property.VCardProperty; |
| 29 |
import ezvcard.util.HtmlUtils; |
| 30 |
import ezvcard.util.XmlUtils; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public class Sensei<T extends VCardProperty> { |
| 63 |
private final VCardPropertyScribe<T> scribe; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public static <T extends VCardProperty> Sensei<T> create(VCardPropertyScribe<T> scribe) { |
| 71 |
return new Sensei<>(scribe); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public Sensei(VCardPropertyScribe<T> scribe) { |
| 79 |
this.scribe = scribe; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public ParseTextTest assertParseText(String value) { |
| 88 |
return new ParseTextTest(value); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
public ParseXmlTest assertParseXml(String innerXml) { |
| 97 |
return new ParseXmlTest(innerXml); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public ParseHtmlTest assertParseHtml(String html) { |
| 106 |
return new ParseHtmlTest(html); |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
public ParseJsonTest assertParseJson(String value) { |
| 115 |
return assertParseJson(JCardValue.single(value)); |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
public ParseJsonTest assertParseJson(JCardValue value) { |
| 124 |
return new ParseJsonTest(value); |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
public DataTypeTest assertDataType(T property) { |
| 133 |
return new DataTypeTest(property); |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
public PrepareParamsTest assertPrepareParams(T property) { |
| 142 |
return new PrepareParamsTest(property); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
public WriteTextTest assertWriteText(T property) { |
| 151 |
return new WriteTextTest(property); |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
public WriteXmlTest assertWriteXml(T property) { |
| 160 |
return new WriteXmlTest(property); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
public WriteJsonTest assertWriteJson(T property) { |
| 169 |
return new WriteJsonTest(property); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
public class DataTypeTest { |
| 177 |
protected final T property; |
| 178 |
private VCardVersion version[] = VCardVersion.values(); |
| 179 |
|
| 180 |
public DataTypeTest(T property) { |
| 181 |
this.property = property; |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
public DataTypeTest versions(VCardVersion... version) { |
| 190 |
this.version = version; |
| 191 |
return this; |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
public void run(VCardDataType expected) { |
| 199 |
for (VCardVersion version : this.version) { |
| 200 |
VCardDataType actual = scribe.dataType(property, version); |
| 201 |
assertEquals("Version " + version, expected, actual); |
| 202 |
} |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
public class PrepareParamsTest { |
| 211 |
protected final T property; |
| 212 |
private VCardVersion versions[] = VCardVersion.values(); |
| 213 |
private VCard vcard = new VCard(); |
| 214 |
private VCardParameters expected = new VCardParameters(); |
| 215 |
|
| 216 |
public PrepareParamsTest(T property) { |
| 217 |
this.property = property; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
public PrepareParamsTest versions(VCardVersion... versions) { |
| 226 |
this.versions = versions; |
| 227 |
return this; |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
public PrepareParamsTest vcard(VCard vcard) { |
| 236 |
this.vcard = vcard; |
| 237 |
return this; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
public PrepareParamsTest expected(String name, String... values) { |
| 247 |
for (String value : values) { |
| 248 |
expected.put(name, value); |
| 249 |
} |
| 250 |
return this; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
public void run() { |
| 257 |
for (VCardVersion version : versions) { |
| 258 |
VCardParameters actual = scribe.prepareParameters(property, version, vcard); |
| 259 |
assertEquals("Actual: " + actual, expected.size(), actual.size()); |
| 260 |
|
| 261 |
for (Map.Entry<String, List<String>> entry : expected) { |
| 262 |
String expectedKey = entry.getKey(); |
| 263 |
List<String> expectedValues = entry.getValue(); |
| 264 |
|
| 265 |
List<String> actualValues = actual.get(expectedKey); |
| 266 |
assertEquals("Actual: " + actual, expectedValues.size(), actualValues.size()); |
| 267 |
for (String expectedValue : expectedValues) { |
| 268 |
assertTrue("Actual: " + actual, actualValues.contains(expectedValue)); |
| 269 |
} |
| 270 |
} |
| 271 |
} |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
public class WriteTextTest { |
| 280 |
protected final T property; |
| 281 |
private VCardVersion versions[] = VCardVersion.values(); |
| 282 |
private boolean includeTrailingSemicolons = false; |
| 283 |
|
| 284 |
public WriteTextTest(T property) { |
| 285 |
this.property = property; |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
public WriteTextTest versions(VCardVersion... versions) { |
| 294 |
this.versions = versions; |
| 295 |
return this; |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
public WriteTextTest includeTrailingSemicolons(boolean include) { |
| 305 |
includeTrailingSemicolons = include; |
| 306 |
return this; |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
public void skipMe() { |
| 313 |
run(SkipMeException.class); |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
public void run(String expected) { |
| 321 |
for (VCardVersion version : versions) { |
| 322 |
String actual = scribe.writeText(property, new WriteContext(version, null, includeTrailingSemicolons)); |
| 323 |
assertEquals("Version " + version, expected, actual); |
| 324 |
} |
| 325 |
} |
| 326 |
|
| 327 |
public void run(Class<? extends RuntimeException> expected) { |
| 328 |
for (VCardVersion version : versions) { |
| 329 |
try { |
| 330 |
scribe.writeText(property, new WriteContext(version, null, false)); |
| 331 |
fail("Expected " + expected.getSimpleName()); |
| 332 |
} catch (RuntimeException t) { |
| 333 |
assertEquals("Expected " + expected.getSimpleName() + ", but was " + t.getClass().getSimpleName(), expected, t.getClass()); |
| 334 |
} |
| 335 |
} |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
public class WriteXmlTest { |
| 344 |
protected final T property; |
| 345 |
|
| 346 |
public WriteXmlTest(T property) { |
| 347 |
this.property = property; |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
public void run(String expectedInnerXml) { |
| 356 |
Document actual = createXCardElement(); |
| 357 |
scribe.writeXml(property, actual.getDocumentElement()); |
| 358 |
|
| 359 |
Document expected = createXCardElement(expectedInnerXml); |
| 360 |
|
| 361 |
assertXMLEqual(XmlUtils.toString(actual), expected, actual); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
public class WriteJsonTest { |
| 370 |
protected final T property; |
| 371 |
|
| 372 |
public WriteJsonTest(T property) { |
| 373 |
this.property = property; |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
public JCardValue run() { |
| 381 |
return scribe.writeJson(property); |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
public void run(JCardValue expected) { |
| 389 |
JCardValue value = run(); |
| 390 |
assertEquals(expected.getValues(), value.getValues()); |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
public void run(String expected) { |
| 398 |
JCardValue value = run(); |
| 399 |
assertEquals(1, value.getValues().size()); |
| 400 |
assertEquals(expected, value.getValues().get(0).getValue()); |
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
private abstract class ParseTest<U extends ParseTest<U>> { |
| 408 |
protected VCardParameters parameters = new VCardParameters(); |
| 409 |
protected Integer[] parseWarningCodes = new Integer[0]; |
| 410 |
|
| 411 |
@SuppressWarnings("unchecked") |
| 412 |
private final U this_ = (U) this; |
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
public U param(String name, String value) { |
| 421 |
parameters.put(name, value); |
| 422 |
return this_; |
| 423 |
} |
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
public U params(VCardParameters parameters) { |
| 431 |
this.parameters = parameters; |
| 432 |
return this_; |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
public U warnings(Integer... codes) { |
| 442 |
parseWarningCodes = codes; |
| 443 |
return this_; |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
public void run() { |
| 450 |
run(null, -1); |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
public void run(Check<T> check) { |
| 458 |
run(check, -1); |
| 459 |
} |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
public void run(final T expected) { |
| 467 |
run(actual -> assertEquals(expected, actual), -1); |
| 468 |
} |
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
public void cannotParse(Integer expectedCode) { |
| 476 |
run(null, expectedCode); |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
protected abstract void run(Check<T> check, Integer cannotParseExceptionCode); |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
public class ParseTextTest extends ParseTest<ParseTextTest> { |
| 497 |
private final String value; |
| 498 |
private VCardDataType dataType; |
| 499 |
private VCardVersion versions[] = VCardVersion.values(); |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
public ParseTextTest(String value) { |
| 505 |
this.value = value; |
| 506 |
} |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
public ParseTextTest dataType(VCardDataType dataType) { |
| 514 |
this.dataType = dataType; |
| 515 |
return this; |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
public ParseTextTest versions(VCardVersion... versions) { |
| 524 |
this.versions = versions; |
| 525 |
return this; |
| 526 |
} |
| 527 |
|
| 528 |
@Override |
| 529 |
protected void run(Check<T> check, Integer cannotParseExceptionCode) { |
| 530 |
for (VCardVersion version : versions) { |
| 531 |
VCardDataType dataType = this.dataType; |
| 532 |
if (dataType == null) { |
| 533 |
dataType = scribe.defaultDataType(version); |
| 534 |
} |
| 535 |
|
| 536 |
ParseContext context = new ParseContext(); |
| 537 |
context.setVersion(version); |
| 538 |
try { |
| 539 |
T property = scribe.parseText(value, dataType, parameters, context); |
| 540 |
|
| 541 |
if (cannotParseExceptionCode == null || cannotParseExceptionCode >= 0) { |
| 542 |
fail("Expected a CannotParseException with code <" + cannotParseExceptionCode + "> to be thrown."); |
| 543 |
} |
| 544 |
|
| 545 |
if (check != null) { |
| 546 |
check.check(property); |
| 547 |
} |
| 548 |
|
| 549 |
assertParseWarnings(context.getWarnings(), parseWarningCodes); |
| 550 |
} catch (CannotParseException e) { |
| 551 |
if (cannotParseExceptionCode == -1) { |
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
throw e; |
| 557 |
} |
| 558 |
|
| 559 |
assertEquals("CannotParseException's parse warning code was wrong.", cannotParseExceptionCode, e.getCode()); |
| 560 |
} |
| 561 |
} |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
public class ParseXmlTest extends ParseTest<ParseXmlTest> { |
| 570 |
private final String innerXml; |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
public ParseXmlTest(String innerXml) { |
| 576 |
this.innerXml = innerXml; |
| 577 |
} |
| 578 |
|
| 579 |
@Override |
| 580 |
protected void run(Check<T> check, Integer cannotParseExceptionCode) { |
| 581 |
try { |
| 582 |
ParseContext context = new ParseContext(); |
| 583 |
context.setVersion(VCardVersion.V4_0); |
| 584 |
Document document = createXCardElement(innerXml); |
| 585 |
Element element = document.getDocumentElement(); |
| 586 |
T property = scribe.parseXml(element, parameters, context); |
| 587 |
|
| 588 |
if (cannotParseExceptionCode == null || cannotParseExceptionCode >= 0) { |
| 589 |
fail("Expected a CannotParseException with code <" + cannotParseExceptionCode + "> to be thrown."); |
| 590 |
} |
| 591 |
|
| 592 |
if (check != null) { |
| 593 |
check.check(property); |
| 594 |
} |
| 595 |
|
| 596 |
assertParseWarnings(context.getWarnings(), parseWarningCodes); |
| 597 |
} catch (CannotParseException e) { |
| 598 |
if (cannotParseExceptionCode == -1) { |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
throw e; |
| 604 |
} |
| 605 |
|
| 606 |
assertEquals("CannotParseException's parse warning code was wrong.", cannotParseExceptionCode, e.getCode()); |
| 607 |
} |
| 608 |
} |
| 609 |
} |
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
public class ParseHtmlTest extends ParseTest<ParseHtmlTest> { |
| 616 |
private final String html; |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
public ParseHtmlTest(String html) { |
| 622 |
this.html = html; |
| 623 |
} |
| 624 |
|
| 625 |
@Override |
| 626 |
public ParseHtmlTest param(String name, String value) { |
| 627 |
throw new UnsupportedOperationException(); |
| 628 |
} |
| 629 |
|
| 630 |
@Override |
| 631 |
public ParseHtmlTest params(VCardParameters parameters) { |
| 632 |
throw new UnsupportedOperationException(); |
| 633 |
} |
| 634 |
|
| 635 |
@Override |
| 636 |
protected void run(Check<T> check, Integer cannotParseExceptionCode) { |
| 637 |
try { |
| 638 |
ParseContext context = new ParseContext(); |
| 639 |
context.setVersion(VCardVersion.V3_0); |
| 640 |
org.jsoup.nodes.Element element = HtmlUtils.toElement(html); |
| 641 |
T property = scribe.parseHtml(new HCardElement(element), context); |
| 642 |
|
| 643 |
if (cannotParseExceptionCode == null || cannotParseExceptionCode >= 0) { |
| 644 |
fail("Expected a CannotParseException with code <" + cannotParseExceptionCode + "> to be thrown."); |
| 645 |
} |
| 646 |
|
| 647 |
if (check != null) { |
| 648 |
check.check(property); |
| 649 |
} |
| 650 |
|
| 651 |
assertParseWarnings(context.getWarnings(), parseWarningCodes); |
| 652 |
} catch (CannotParseException e) { |
| 653 |
if (cannotParseExceptionCode == -1) { |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
throw e; |
| 659 |
} |
| 660 |
|
| 661 |
assertEquals("CannotParseException's parse warning code was wrong.", cannotParseExceptionCode, e.getCode()); |
| 662 |
} |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
public class ParseJsonTest extends ParseTest<ParseJsonTest> { |
| 671 |
private final JCardValue value; |
| 672 |
private VCardDataType dataType = scribe.defaultDataType(VCardVersion.V4_0); |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
public ParseJsonTest(JCardValue value) { |
| 678 |
this.value = value; |
| 679 |
} |
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
public ParseJsonTest dataType(VCardDataType dataType) { |
| 687 |
this.dataType = dataType; |
| 688 |
return this; |
| 689 |
} |
| 690 |
|
| 691 |
@Override |
| 692 |
protected void run(Check<T> check, Integer cannotParseExceptionCode) { |
| 693 |
try { |
| 694 |
ParseContext context = new ParseContext(); |
| 695 |
context.setVersion(VCardVersion.V4_0); |
| 696 |
T property = scribe.parseJson(value, dataType, parameters, context); |
| 697 |
|
| 698 |
if (cannotParseExceptionCode == null || cannotParseExceptionCode >= 0) { |
| 699 |
fail("Expected a CannotParseException with code <" + cannotParseExceptionCode + "> to be thrown."); |
| 700 |
} |
| 701 |
|
| 702 |
if (check != null) { |
| 703 |
check.check(property); |
| 704 |
} |
| 705 |
|
| 706 |
assertParseWarnings(context.getWarnings(), parseWarningCodes); |
| 707 |
} catch (CannotParseException e) { |
| 708 |
if (cannotParseExceptionCode == -1) { |
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
throw e; |
| 714 |
} |
| 715 |
|
| 716 |
assertEquals("CannotParseException's parse warning code was wrong.", cannotParseExceptionCode, e.getCode()); |
| 717 |
} |
| 718 |
} |
| 719 |
} |
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
public interface Check<T extends VCardProperty> { |
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
void check(T property); |
| 731 |
} |
| 732 |
|
| 733 |
private Document createXCardElement() { |
| 734 |
return createXCardElement(""); |
| 735 |
} |
| 736 |
|
| 737 |
private Document createXCardElement(String innerXml) { |
| 738 |
QName qname = scribe.getQName(); |
| 739 |
String localName = qname.getLocalPart(); |
| 740 |
String ns = qname.getNamespaceURI(); |
| 741 |
|
| 742 |
try { |
| 743 |
return XmlUtils.toDocument("<" + localName + " xmlns=\"" + ns + "\">" + innerXml + "</" + localName + ">"); |
| 744 |
} catch (SAXException e) { |
| 745 |
throw new RuntimeException(e); |
| 746 |
} |
| 747 |
} |
| 748 |
} |