466 467 /* 468 * Creates a pseudo schema for the WSDL schema fragments that have the same 469 * targetNamespace. 470 * 471 * <xsd:schema targetNamespace="X"> 472 * <xsd:include schemaLocation="Y1"/> 473 * <xsd:include schemaLocation="Y2"/> 474 * </xsd:schema> 475 * 476 * @param tns targetNamespace of the the schema documents 477 * @param docs collection of systemId for the schema documents that have the 478 * same tns, the collection must have more than one document 479 * @param psuedoSystemId for the created pseudo schema 480 * @return Source of pseudo schema that can be used multiple times 481 */ 482 private @Nullable Source createSameTnsPseudoSchema(String tns, Collection<String> docs, String pseudoSystemId) { 483 assert docs.size() > 1; 484 485 final StringBuilder sb = new StringBuilder("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'"); 486 if (!tns.equals("")) { 487 sb.append(" targetNamespace='").append(tns).append("'"); 488 } 489 sb.append(">\n"); 490 for(String systemId : docs) { 491 sb.append("<xsd:include schemaLocation='").append(systemId).append("'/>\n"); 492 } 493 sb.append("</xsd:schema>\n"); 494 if (LOGGER.isLoggable(Level.FINE)) { 495 LOGGER.log(Level.FINE, "Pseudo Schema for the same tns={0}is {1}", new Object[]{tns, sb}); 496 } 497 498 // override getReader() so that the same source can be used multiple times 499 return new StreamSource(pseudoSystemId) { 500 @Override 501 public Reader getReader() { 502 return new StringReader(sb.toString()); 503 } 504 }; 505 } 506 507 /* 508 * Creates a master pseudo schema importing all WSDL schema fragments with 509 * different tns+pseudo schema for same tns. 510 * <xsd:schema targetNamespace="urn:x-jax-ws-master"> 511 * <xsd:import schemaLocation="Y1" namespace="X1"/> 512 * <xsd:import schemaLocation="Y2" namespace="X2"/> 513 * </xsd:schema> 514 * 515 * @param pseudo a map(tns-->systemId) of schema documents 516 * @return Source of pseudo schema that can be used multiple times 517 */ 518 private Source createMasterPseudoSchema(Map<String, String> docs) { 519 final StringBuilder sb = new StringBuilder("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:x-jax-ws-master'>\n"); 520 for(Map.Entry<String, String> e : docs.entrySet()) { 521 String systemId = e.getValue(); 522 String ns = e.getKey(); 523 sb.append("<xsd:import schemaLocation='").append(systemId).append("'"); 524 if (!ns.equals("")) { 525 sb.append(" namespace='").append(ns).append("'"); 526 } 527 sb.append("/>\n"); 528 } 529 sb.append("</xsd:schema>"); 530 if (LOGGER.isLoggable(Level.FINE)) { 531 LOGGER.log(Level.FINE, "Master Pseudo Schema = {0}", sb); 532 } 533 534 // override getReader() so that the same source can be used multiple times 535 return new StreamSource("file:x-jax-ws-master-doc") { 536 @Override 537 public Reader getReader() { 538 return new StringReader(sb.toString()); 539 } 540 }; 541 } 542 543 protected void doProcess(Packet packet) throws SAXException { 544 getValidator().reset(); | 466 467 /* 468 * Creates a pseudo schema for the WSDL schema fragments that have the same 469 * targetNamespace. 470 * 471 * <xsd:schema targetNamespace="X"> 472 * <xsd:include schemaLocation="Y1"/> 473 * <xsd:include schemaLocation="Y2"/> 474 * </xsd:schema> 475 * 476 * @param tns targetNamespace of the the schema documents 477 * @param docs collection of systemId for the schema documents that have the 478 * same tns, the collection must have more than one document 479 * @param psuedoSystemId for the created pseudo schema 480 * @return Source of pseudo schema that can be used multiple times 481 */ 482 private @Nullable Source createSameTnsPseudoSchema(String tns, Collection<String> docs, String pseudoSystemId) { 483 assert docs.size() > 1; 484 485 final StringBuilder sb = new StringBuilder("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'"); 486 if (!"".equals(tns)) { 487 sb.append(" targetNamespace='").append(tns).append("'"); 488 } 489 sb.append(">\n"); 490 for(String systemId : docs) { 491 sb.append("<xsd:include schemaLocation='").append(systemId).append("'/>\n"); 492 } 493 sb.append("</xsd:schema>\n"); 494 if (LOGGER.isLoggable(Level.FINE)) { 495 LOGGER.log(Level.FINE, "Pseudo Schema for the same tns={0}is {1}", new Object[]{tns, sb}); 496 } 497 498 // override getReader() so that the same source can be used multiple times 499 return new StreamSource(pseudoSystemId) { 500 @Override 501 public Reader getReader() { 502 return new StringReader(sb.toString()); 503 } 504 }; 505 } 506 507 /* 508 * Creates a master pseudo schema importing all WSDL schema fragments with 509 * different tns+pseudo schema for same tns. 510 * <xsd:schema targetNamespace="urn:x-jax-ws-master"> 511 * <xsd:import schemaLocation="Y1" namespace="X1"/> 512 * <xsd:import schemaLocation="Y2" namespace="X2"/> 513 * </xsd:schema> 514 * 515 * @param pseudo a map(tns-->systemId) of schema documents 516 * @return Source of pseudo schema that can be used multiple times 517 */ 518 private Source createMasterPseudoSchema(Map<String, String> docs) { 519 final StringBuilder sb = new StringBuilder("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:x-jax-ws-master'>\n"); 520 for(Map.Entry<String, String> e : docs.entrySet()) { 521 String systemId = e.getValue(); 522 String ns = e.getKey(); 523 sb.append("<xsd:import schemaLocation='").append(systemId).append("'"); 524 if (!"".equals(ns)) { 525 sb.append(" namespace='").append(ns).append("'"); 526 } 527 sb.append("/>\n"); 528 } 529 sb.append("</xsd:schema>"); 530 if (LOGGER.isLoggable(Level.FINE)) { 531 LOGGER.log(Level.FINE, "Master Pseudo Schema = {0}", sb); 532 } 533 534 // override getReader() so that the same source can be used multiple times 535 return new StreamSource("file:x-jax-ws-master-doc") { 536 @Override 537 public Reader getReader() { 538 return new StringReader(sb.toString()); 539 } 540 }; 541 } 542 543 protected void doProcess(Packet packet) throws SAXException { 544 getValidator().reset(); |