1 16 19 package org.apache.xalan.processor; 20 21 import javax.xml.transform.OutputKeys ; 22 import javax.xml.transform.TransformerException ; 23 24 import org.apache.xalan.templates.ElemTemplateElement; 25 import org.apache.xalan.templates.OutputProperties; 26 import org.apache.xml.serializer.OutputPropertiesFactory; 27 import org.apache.xml.utils.QName; 28 import org.apache.xml.utils.SystemIDResolver; 29 import org.xml.sax.Attributes ; 30 31 36 class ProcessorOutputElem extends XSLTElementProcessor 37 { 38 39 42 private OutputProperties m_outputProperties; 43 44 49 public void setCdataSectionElements(java.util.Vector newValue) 50 { 51 m_outputProperties.setQNameProperties(OutputKeys.CDATA_SECTION_ELEMENTS, newValue); 52 } 53 54 59 public void setDoctypePublic(String newValue) 60 { 61 m_outputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, newValue); 62 } 63 64 69 public void setDoctypeSystem(String newValue) 70 { 71 m_outputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, newValue); 72 } 73 74 79 public void setEncoding(String newValue) 80 { 81 m_outputProperties.setProperty(OutputKeys.ENCODING, newValue); 82 } 83 84 89 public void setIndent(boolean newValue) 90 { 91 m_outputProperties.setBooleanProperty(OutputKeys.INDENT, newValue); 92 } 93 94 99 public void setMediaType(String newValue) 100 { 101 m_outputProperties.setProperty(OutputKeys.MEDIA_TYPE, newValue); 102 } 103 104 109 public void setMethod(org.apache.xml.utils.QName newValue) 110 { 111 m_outputProperties.setQNameProperty(OutputKeys.METHOD, newValue); 112 } 113 114 119 public void setOmitXmlDeclaration(boolean newValue) 120 { 121 m_outputProperties.setBooleanProperty(OutputKeys.OMIT_XML_DECLARATION, newValue); 122 } 123 124 129 public void setStandalone(boolean newValue) 130 { 131 m_outputProperties.setBooleanProperty(OutputKeys.STANDALONE, newValue); 132 } 133 134 139 public void setVersion(String newValue) 140 { 141 m_outputProperties.setProperty(OutputKeys.VERSION, newValue); 142 } 143 144 148 public void setForeignAttr(String attrUri, String attrLocalName, String attrRawName, String attrValue) 149 { 150 QName key = new QName(attrUri, attrLocalName); 151 m_outputProperties.setProperty(key, attrValue); 152 } 153 154 158 public void addLiteralResultAttribute(String attrUri, String attrLocalName, String attrRawName, String attrValue) 159 { 160 QName key = new QName(attrUri, attrLocalName); 161 m_outputProperties.setProperty(key, attrValue); 162 } 163 164 182 public void startElement( 183 StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) 184 throws org.xml.sax.SAXException 185 { 186 m_outputProperties = new OutputProperties(); 188 189 m_outputProperties.setDOMBackPointer(handler.getOriginatingNode()); 190 m_outputProperties.setLocaterInfo(handler.getLocator()); 191 m_outputProperties.setUid(handler.nextUid()); 192 setPropertiesFromAttributes(handler, rawName, attributes, this); 193 194 String entitiesFileName = 197 (String ) m_outputProperties.getProperties().get(OutputPropertiesFactory.S_KEY_ENTITIES); 198 199 if (null != entitiesFileName) 200 { 201 try 202 { 203 String absURL = SystemIDResolver.getAbsoluteURI(entitiesFileName, 204 handler.getBaseIdentifier()); 205 m_outputProperties.getProperties().put(OutputPropertiesFactory.S_KEY_ENTITIES, absURL); 206 } 207 catch(TransformerException te) 208 { 209 handler.error(te.getMessage(), te); 210 } 211 } 212 213 handler.getStylesheet().setOutput(m_outputProperties); 214 215 ElemTemplateElement parent = handler.getElemTemplateElement(); 216 parent.appendChild(m_outputProperties); 217 218 m_outputProperties = null; 219 } 220 } 221 | Popular Tags |