protected WXSSchema nouveauSchemaInclu( final URL urlSchemaParent, final String schemaLocation, final String espaceImport, final WXSSchema schemaParent) throws JaxeException { try { final URL urls = resoudreURI(getURLParent(urlSchemaParent), schemaLocation); if (urls == null) throw new JaxeException("include/import : location not found : " + schemaLocation); for (WXSSchema schemaInclu : schemasInclu) if (schemaInclu.getURL().toURI().normalize().equals(urls.toURI().normalize())) { ajouterEspaces( schemaInclu, schemaParent, espaceImport); // une chance de plus de trouver un pr?fixe return (schemaInclu); } final WXSSchema schemaInclu = new WXSSchema(lireDocument(urls), urls, this, schemaParent); ajouterEspaces(schemaInclu, schemaParent, espaceImport); schemasInclu.add(schemaInclu); schemaInclu.inclusions(); return (schemaInclu); } catch (final MalformedURLException ex) { throw new JaxeException("include/import : MalformedURLException: " + ex.getMessage(), ex); } catch (final URISyntaxException ex) { throw new JaxeException("include/import : URISyntaxException: " + ex.getMessage(), ex); } catch (final TransformerException ex) { throw new JaxeException("include/import : TransformerException: " + ex.getMessage(), ex); } }
/** Renvoie true si l'espace de nom est d?fini dans le sch?ma */ public boolean aEspace(final String espace) { final String targetNamespace = schema.getTargetNamespace(); if (espace == null) { if (targetNamespace == null || targetNamespace.equals("")) return (true); if (espaceVersPrefixe.containsKey("")) return (true); // cas des ?l?ments locaux sans espace de noms : final boolean qualified = "qualified".equals(schema.getElementFormDefault()); if (!qualified) return (true); } else { if (espace.equals(targetNamespace)) return (true); if (espaceVersPrefixe.containsKey(espace)) return (true); } return (false); }
/** * Renvoie l'espace de noms d'un attribut ? partir de son nom complet (avec le pr?fixe s'il y en a * un) */ public String espaceAttribut(final String nomAttribut) { if (nomAttribut == null) return (null); final String prefixe = prefixeNom(nomAttribut); if (prefixe == null) return (null); if ("xml".equals(prefixe)) return ("http://www.w3.org/XML/1998/namespace"); return (schema.espacePrefixe(prefixe)); }
private void ajouterEspaces( final WXSSchema sch, final WXSSchema schemaParent, final String espaceImport) { if (espaceImport != null && espaceVersPrefixe.get(espaceImport) == null) { String prefixe = sch.prefixeEspace(espaceImport); if (prefixe != null) espaceVersPrefixe.put(espaceImport, prefixe); else if (schemaParent != null) { prefixe = schemaParent.prefixeEspace(espaceImport); if (prefixe != null) espaceVersPrefixe.put(espaceImport, prefixe); } } // toujours ajouter targetNamespace ? final String targetNamespace = sch.getTargetNamespace(); if (targetNamespace != null && !"".equals(targetNamespace)) { final String prefixe = sch.prefixeEspace(targetNamespace); if (prefixe != null) espaceVersPrefixe.put(targetNamespace, prefixe); } }
public JaxeWXS(final URL schemaURL, final Config cfg) throws JaxeException { this.cfg = cfg; schemasInclu = new HashSet<WXSSchema>(); espaceVersPrefixe = new HashMap<String, String>(); schema = new WXSSchema(lireDocument(schemaURL), schemaURL, this, null); ajouterEspaces(schema, null, null); schemasInclu.add(schema); schema.inclusions(); lTousElements = new LinkedHashSet<WXSElement>(); for (final WXSSchema sch : schemasInclu) lTousElements.addAll(sch.listeTousElements()); for (final WXSSchema sch : schemasInclu) sch .resoudreReferences(); // WXSAny.resoudreReferences() a besoin de cet objet JaxeWXS, c'est // donc appel? plus tard hRefElementVersWXS = new HashMap<Element, WXSElement>(); hRefAttributVersWXS = new HashMap<Element, WXSAttribute>(); hNomVersWXS = new HashMap<String, ArrayList<WXSElement>>(); for (WXSElement element : lTousElements) { hRefElementVersWXS.put(element.getDOMElement(), element); if (element.getName() != null && element.getRef() == null) { ArrayList<WXSElement> listeWXS = hNomVersWXS.get(element.getName()); if (listeWXS == null) { listeWXS = new ArrayList<WXSElement>(); hNomVersWXS.put(element.getName(), listeWXS); } listeWXS.add(element); } } for (WXSElement element : lTousElements) { final ArrayList<WXSAttribute> attributs = element.listeAttributs(); if (attributs != null) { for (WXSAttribute attribut : attributs) hRefAttributVersWXS.put(attribut.getDOMElement(), attribut); } } }
public void resoudreReferences(final WXSSchema schema, final WXSThing redefine) { if (simpleType != null) simpleType.resoudreReferences(schema, redefine); if (itemType != null && simpleType == null) { final String tns = domElement.lookupNamespaceURI(JaxeWXS.prefixeNom(itemType)); final WXSType wxsType = schema.resoudreReferenceType(JaxeWXS.valeurLocale(itemType), tns, redefine); if (wxsType instanceof WXSSimpleType) simpleType = (WXSSimpleType) wxsType; else { final String espaceSchema = domElement.getNamespaceURI(); if (!espaceSchema.equals(tns)) itemType = null; // si le type n'a pas �t� r�solu il doit �tre un type des sch�mas XML } } }
/** * Renvoie l'espace de noms cible du sch?ma (attribut targetNamespace avec WXS). Attention: Le * concept d'un espace cible unique pour un sch?ma n'existe pas avec Relax NG. */ public String espaceCible() { return (schema.getTargetNamespace()); }
/** Renvoie la liste des espaces de noms (String) utilis?s par ce sch?ma. */ public ArrayList<String> listeEspaces() { final LinkedHashSet<String> liste = new LinkedHashSet<String>(); if (schema.getTargetNamespace() != null) liste.add(schema.getTargetNamespace()); for (final String s : espaceVersPrefixe.keySet()) liste.add(s); return (new ArrayList<String>(liste)); }