List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute
public void writeAttribute(String localName, String value) throws XMLStreamException;
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected void addRootValidatorSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:for-each"); xmlStreamWriter.writeAttribute("select", "tp:validator"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:copy-of"); xmlStreamWriter.writeAttribute("select", "."); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:apply-templates"); xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()"); xmlStreamWriter.writeEndElement();// w w w.j av a2 s . c om xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:call-template"); xmlStreamWriter.writeAttribute("name", "addValidators"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected void addRootConverterSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:for-each"); xmlStreamWriter.writeAttribute("select", "tp:converter"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:copy-of"); xmlStreamWriter.writeAttribute("select", "."); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:apply-templates"); xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()"); xmlStreamWriter.writeEndElement();/*from www.j a v a 2s . c om*/ xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:call-template"); xmlStreamWriter.writeAttribute("name", "addConverters"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected void addRootLifeCycleSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:for-each"); xmlStreamWriter.writeAttribute("select", "tp:lifecycle"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:copy-of"); xmlStreamWriter.writeAttribute("select", "."); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:apply-templates"); xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()"); xmlStreamWriter.writeEndElement();/* ww w. j ava 2 s .c o m*/ xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:call-template"); xmlStreamWriter.writeAttribute("name", "addLifeCycles"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected void addRootNavigationRuleSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:for-each"); xmlStreamWriter.writeAttribute("select", "tp:navigation-rule"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:copy-of"); xmlStreamWriter.writeAttribute("select", "."); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:apply-templates"); xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()"); xmlStreamWriter.writeEndElement();//from www . j a va2 s . co m xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:call-template"); xmlStreamWriter.writeAttribute("name", "addNavigationRules"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected void addRootManagedBeanSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:for-each"); xmlStreamWriter.writeAttribute("select", "tp:managed-bean"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:copy-of"); xmlStreamWriter.writeAttribute("select", "."); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:apply-templates"); xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()"); xmlStreamWriter.writeEndElement();/*from w ww. ja v a2 s.c o m*/ xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("xsl:call-template"); xmlStreamWriter.writeAttribute("name", "addManagedBeans"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
protected boolean addApplicationChildren(PluginDescriptor pluginDescriptor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { boolean added = false; xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("name", "addApplicationChildren"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("application"); xmlStreamWriter.writeCharacters("\n"); Set<String> viewHandlerStringSet = new HashSet<String>(); for (Extension extension : getExtensions(pluginDescriptor, "view-handler")) { for (Parameter parameter : extension.getParameters("view-handler")) { viewHandlerStringSet.add(parameter.valueAsString()); added = true;//from w ww . java 2 s . c o m } } Comparator<String> comparator = new Comparator<String>() { public int compare(String string1, String string2) { return string1.compareTo(string2); }; }; List<String> viewHandlerStringList = new ArrayList<String>(); viewHandlerStringList.addAll(viewHandlerStringSet); Collections.sort(viewHandlerStringList, comparator); for (String viewHandler : viewHandlerStringList) { xmlStreamWriter.writeStartElement("view-handler"); xmlStreamWriter.writeCharacters(viewHandler); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); added = true; } Set<String> elResolverStringSet = new HashSet<String>(); for (Extension extension : getExtensions(pluginDescriptor, "el-resolver")) { for (Parameter parameter : extension.getParameters("el-resolver")) { elResolverStringSet.add(parameter.valueAsString()); added = true; } } List<String> elResolverStringList = new ArrayList<String>(); elResolverStringList.addAll(elResolverStringSet); Collections.sort(elResolverStringList, comparator); for (String elResolver : elResolverStringList) { xmlStreamWriter.writeStartElement("el-resolver"); xmlStreamWriter.writeCharacters(elResolver); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); added = true; } for (Extension extension : getExtensions(pluginDescriptor, "localeConfig")) { xmlStreamWriter.writeStartElement("locale-config"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("default-locale"); xmlStreamWriter.writeCharacters(extension.getParameter("default-locale").valueAsString()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); for (Parameter parameter : extension.getParameters("supported-locale")) { xmlStreamWriter.writeStartElement("supported-locale"); xmlStreamWriter.writeCharacters(parameter.valueAsString()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); added = true; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); return added; }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add a global validator templates//from w ww .j ava 2 s . c om * * @param warPluginDescriptor * @param xmlStreamWriter * @throws XMLStreamException */ protected boolean addGlobalValidatorTemplates(PluginDescriptor warPluginDescriptor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { boolean added = false; xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("name", "addValidators"); xmlStreamWriter.writeCharacters("\n"); Map<String, Extension> validatorMap = new HashMap<String, Extension>(); for (Extension nonDefaultExtension : getGlobalValidatorExtensions(warPluginDescriptor, true)) { String validatorId = nonDefaultExtension.getParameter("validator-id").valueAsString(); validatorMap.put(validatorId, nonDefaultExtension); added = true; } for (Extension nonDefaultExtension : getGlobalValidatorExtensions(warPluginDescriptor, false)) { String validatorId = nonDefaultExtension.getParameter("validator-id").valueAsString(); Extension validatorExtension = validatorMap.get(validatorId); if (validatorExtension != null) { logger.debug(nonDefaultExtension.getUniqueId() + " overrides " + validatorExtension.getUniqueId()); } validatorMap.put(validatorId, nonDefaultExtension); added = true; } List<Extension> extensions = new ArrayList<Extension>(); extensions.addAll(validatorMap.values()); Comparator<Object> comparator = new Comparator<Object>() { public int compare(Object obj1, Object obj2) { Extension e1 = (Extension) obj1; Extension e2 = (Extension) obj2; return e1.getParameter("validator-id").valueAsString() .compareTo(e2.getParameter("validator-id").valueAsString()); }; }; Collections.sort(extensions, comparator); for (Extension extension : extensions) { Parameter handlerClass = extension.getParameter("validator-class"); String validatorClass = null; if (handlerClass != null) { validatorClass = handlerClass.valueAsString(); } addGlobalValidator(extension.getParameter("validator-id").valueAsString(), validatorClass, xmlStreamWriter); added = true; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); return added; }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add the global template if-clause for validatorId * //from w w w . ja v a 2 s . com * @param validatorId * @param validatorClass * @param xmlStreamWriter * @throws XMLStreamException */ protected void addGlobalValidator(String validatorId, String validatorClass, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:if"); xmlStreamWriter.writeAttribute("test", "count(tp:validator[tp:validator-id = '" + validatorId + "']) = 0"); xmlStreamWriter.writeStartElement("validator"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("validator-id"); xmlStreamWriter.writeCharacters(validatorId); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); if (validatorClass != null) { xmlStreamWriter.writeStartElement("validator-class"); xmlStreamWriter.writeCharacters(validatorClass); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add a global converter templates/*from w w w.j ava 2 s. c om*/ * * @param warPluginDescriptor * @param xmlStreamWriter * @throws XMLStreamException */ protected boolean addGlobalConverterTemplates(PluginDescriptor warPluginDescriptor, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { boolean added = false; xmlStreamWriter.writeStartElement("xsl:template"); xmlStreamWriter.writeAttribute("name", "addConverters"); xmlStreamWriter.writeCharacters("\n"); Map<String, Extension> converterMap = new HashMap<String, Extension>(); for (Extension nonDefaultExtension : getGlobalConverterExtensions(warPluginDescriptor, true)) { String converterId = nonDefaultExtension.getParameter("converter-id").valueAsString(); converterMap.put(converterId, nonDefaultExtension); added = true; } for (Extension nonDefaultExtension : getGlobalConverterExtensions(warPluginDescriptor, false)) { String converterId = nonDefaultExtension.getParameter("converter-id").valueAsString(); Extension converterExtension = converterMap.get(converterId); if (converterExtension != null) { logger.debug(nonDefaultExtension.getUniqueId() + " overrides " + converterExtension.getUniqueId()); } converterMap.put(converterId, nonDefaultExtension); added = true; } List<Extension> extensions = new ArrayList<Extension>(); extensions.addAll(converterMap.values()); Comparator<Object> comparator = new Comparator<Object>() { public int compare(Object obj1, Object obj2) { Extension e1 = (Extension) obj1; Extension e2 = (Extension) obj2; return e1.getParameter("converter-id").valueAsString() .compareTo(e2.getParameter("converter-id").valueAsString()); }; }; Collections.sort(extensions, comparator); for (Extension extension : extensions) { Parameter handlerClass = extension.getParameter("converter-class"); String converterClass = null; if (handlerClass != null) { converterClass = handlerClass.valueAsString(); } addGlobalConverter(extension.getParameter("converter-id").valueAsString(), converterClass, xmlStreamWriter); added = true; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); return added; }
From source file:org.tolven.assembler.facesconfig.FacesConfigAssembler.java
/** * Add the global template if-clause for converterId * //from ww w. j a va 2s .co m * @param converterId * @param converterClass * @param xmlStreamWriter * @throws XMLStreamException */ protected void addGlobalConverter(String converterId, String converterClass, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { xmlStreamWriter.writeStartElement("xsl:if"); xmlStreamWriter.writeAttribute("test", "count(tp:converter[tp:converter-id = '" + converterId + "']) = 0"); xmlStreamWriter.writeStartElement("converter"); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("converter-id"); xmlStreamWriter.writeCharacters(converterId); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); if (converterClass != null) { xmlStreamWriter.writeStartElement("converter-class"); xmlStreamWriter.writeCharacters(converterClass); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }