/** * Add the xml:spaces="preserve" attribute if the string has leading or trailing spaces * * @param xs the string to check */ protected static void preserveSpaces(STXstring xs) { String text = xs.getStringValue(); if (text != null && text.length() > 0) { char firstChar = text.charAt(0); char lastChar = text.charAt(text.length() - 1); if(Character.isWhitespace(firstChar) || Character.isWhitespace(lastChar)) { XmlCursor c = xs.newCursor(); c.toNextToken(); c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve"); c.dispose(); } } }
/** * Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces * * @param xs the string to check */ static void preserveSpaces(XmlString xs) { String text = xs.getStringValue(); if (text != null && (text.startsWith(" ") || text.endsWith(" "))) { XmlCursor c = xs.newCursor(); c.toNextToken(); c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve"); c.dispose(); } }
/** * The low level code to insert {@code <c:chart>} tag into * {@code<a:graphicData>}. * * Here is the schema (ECMA-376): * <pre> * {@code * <complexType name="CT_GraphicalObjectData"> * <sequence> * <any minOccurs="0" maxOccurs="unbounded" processContents="strict"/> * </sequence> * <attribute name="uri" type="xsd:token"/> * </complexType> * } * </pre> */ private void appendChartElement(CTGraphicalObjectData data, String id) { String r_namespaceUri = STRelationshipId.type.getName().getNamespaceURI(); String c_namespaceUri = XSSFDrawing.NAMESPACE_C; XmlCursor cursor = data.newCursor(); cursor.toNextToken(); cursor.beginElement(new QName(c_namespaceUri, "chart", "c")); cursor.insertAttributeWithValue(new QName(r_namespaceUri, "id", "r"), id); cursor.dispose(); data.setUri(c_namespaceUri); }
if (hashAlgo == null) { int hash = CryptoFunctions.createXorVerifier1(password); cur.insertAttributeWithValue(getAttrName(prefix, "password"), String.format(Locale.ROOT, "%04X", hash).toUpperCase(Locale.ROOT)); } else { cur.insertAttributeWithValue(getAttrName(prefix, "algorithmName"), hashAlgo.jceId); cur.insertAttributeWithValue(getAttrName(prefix, "hashValue"), DatatypeConverter.printBase64Binary(hash)); cur.insertAttributeWithValue(getAttrName(prefix, "saltValue"), DatatypeConverter.printBase64Binary(salt)); cur.insertAttributeWithValue(getAttrName(prefix, "spinCount"), ""+spinCount);
protected void write(OutputStream out) throws IOException { XmlObject rootObject = XmlObject.Factory.newInstance(); XmlCursor rootCursor = rootObject.newCursor(); rootCursor.toNextToken(); rootCursor.beginElement("xml"); for(int i=0; i < _items.size(); i++){ XmlCursor xc = _items.get(i).newCursor(); rootCursor.beginElement(_qnames.get(i)); while(xc.toNextToken() == XmlCursor.TokenType.ATTR) { Node anode = xc.getDomNode(); rootCursor.insertAttributeWithValue(anode.getLocalName(), anode.getNamespaceURI(), anode.getNodeValue()); } xc.toStartDoc(); xc.copyXmlContents(rootCursor); rootCursor.toNextToken(); xc.dispose(); } rootCursor.dispose(); rootObject.save(out, DEFAULT_XML_OPTIONS); }
cur1.toEndToken(); cur1.beginElement("objectPr", XSSFRelation.NS_SPREADSHEETML); cur1.insertAttributeWithValue("id", PackageRelationshipTypes.CORE_PROPERTIES_ECMA376_NS, imgSheetPR.getId()); cur1.insertAttributeWithValue("defaultSize", "0"); cur1.beginElement("anchor", XSSFRelation.NS_SPREADSHEETML); cur1.insertAttributeWithValue("moveWithCells", "1");
cur.beginElement(new QName(drawNS, "compatExt", "a14")); cur.insertNamespace("a14", drawNS); cur.insertAttributeWithValue("spid", "_x0000_s1"); cur.dispose();
if (typeName != null) xmlc.insertAttributeWithValue(XSI_TYPE, formatQName(xmlc, typeName)); xmlc.insertAttributeWithValue(attr.getName(), formatQName(xmlc, arrayType.getQName()) + arrayType.soap11DimensionString()); continue; xmlc.insertAttributeWithValue(attr.getName(), defaultValue == null ? sampleDataForSimpleType(attr.getType()) : defaultValue);
/** * Add the xml:spaces="preserve" attribute if the string has leading or trailing spaces * * @param xs the string to check */ protected static void preserveSpaces(STXstring xs) { String text = xs.getStringValue(); if (text != null && text.length() > 0) { char firstChar = text.charAt(0); char lastChar = text.charAt(text.length() - 1); if(Character.isWhitespace(firstChar) || Character.isWhitespace(lastChar)) { XmlCursor c = xs.newCursor(); c.toNextToken(); c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve"); c.dispose(); } } }
/** * Add the xml:spaces="preserve" attribute if the string has leading or trailing spaces * * @param xs the string to check */ protected static void preserveSpaces(STXstring xs) { String text = xs.getStringValue(); if (text != null && text.length() > 0) { char firstChar = text.charAt(0); char lastChar = text.charAt(text.length() - 1); if(Character.isWhitespace(firstChar) || Character.isWhitespace(lastChar)) { XmlCursor c = xs.newCursor(); c.toNextToken(); c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve"); c.dispose(); } } }
/** * Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces * * @param xs the string to check */ static void preserveSpaces(XmlString xs) { String text = xs.getStringValue(); if (text != null && (text.startsWith(" ") || text.endsWith(" "))) { XmlCursor c = xs.newCursor(); c.toNextToken(); c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve"); c.dispose(); } }
/** * Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces * * @param xs the string to check */ static void preserveSpaces(XmlString xs) { String text = xs.getStringValue(); if (text != null && (text.startsWith(" ") || text.endsWith(" "))) { XmlCursor c = xs.newCursor(); c.toNextToken(); c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve"); c.dispose(); } }
@Deprecated private void addMessageFilter(ParameterContainer parameters, XmlCursor cur) { cur.beginElement(WSN_B.createQNameFor("MessageContent")); cur.insertAttributeWithValue("Dialect", getStringValueFor(SUBSCRIBE_FILTER_MESSAGE_CONTENT_DIALECT, parameters)); cur.insertChars("@MSG_CONT_FILTER@"); cur.toNextToken(); }
/** * Escapes the reserved characters in a value of an attribute * * @param value Unescaped text * @return The escaped text */ public String escapeAttributeValue(Object value) { String text = ScriptRuntime.toString(value); if (text.length() == 0) return ""; XmlObject xo = XmlObject.Factory.newInstance(); XmlCursor cursor = xo.newCursor(); cursor.toNextToken(); cursor.beginElement("a"); cursor.insertAttributeWithValue("a", text); cursor.dispose(); String elementText = xo.toString(); int begin = elementText.indexOf('"'); int end = elementText.lastIndexOf('"'); return elementText.substring(begin + 1, end); }
@Deprecated private void addTopicFilter(ParameterContainer parameters, XmlCursor cur) { cur.beginElement(WSN_B.createQNameFor("TopicExpression")); cur.insertAttributeWithValue("Dialect", getStringValueFor(SUBSCRIBE_FILTER_TOPIC_DIALECT, parameters)); cur.insertChars(getStringValueFor(SUBSCRIBE_FILTER_TOPIC, parameters)); cur.toNextToken(); }
protected void write(OutputStream out) throws IOException { XmlObject rootObject = XmlObject.Factory.newInstance(); XmlCursor rootCursor = rootObject.newCursor(); rootCursor.toNextToken(); rootCursor.beginElement("xml"); for(int i=0; i < _items.size(); i++){ XmlCursor xc = _items.get(i).newCursor(); rootCursor.beginElement(_qnames.get(i)); while(xc.toNextToken() == XmlCursor.TokenType.ATTR) { Node anode = xc.getDomNode(); rootCursor.insertAttributeWithValue(anode.getLocalName(), anode.getNamespaceURI(), anode.getNodeValue()); } xc.toStartDoc(); xc.copyXmlContents(rootCursor); rootCursor.toNextToken(); xc.dispose(); } rootCursor.dispose(); XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSavePrettyPrint(); HashMap<String, String> map = new HashMap<String, String>(); map.put("urn:schemas-microsoft-com:vml", "v"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("urn:schemas-microsoft-com:office:excel", "x"); xmlOptions.setSaveSuggestedPrefixes(map); rootObject.save(out, xmlOptions); }
protected void write(OutputStream out) throws IOException { XmlObject rootObject = XmlObject.Factory.newInstance(); XmlCursor rootCursor = rootObject.newCursor(); rootCursor.toNextToken(); rootCursor.beginElement("xml"); for(int i=0; i < _items.size(); i++){ XmlCursor xc = _items.get(i).newCursor(); rootCursor.beginElement(_qnames.get(i)); while(xc.toNextToken() == XmlCursor.TokenType.ATTR) { Node anode = xc.getDomNode(); rootCursor.insertAttributeWithValue(anode.getLocalName(), anode.getNamespaceURI(), anode.getNodeValue()); } xc.toStartDoc(); xc.copyXmlContents(rootCursor); rootCursor.toNextToken(); xc.dispose(); } rootCursor.dispose(); rootObject.save(out, DEFAULT_XML_OPTIONS); }
@Deprecated public String buildNotifyRequestLegacy(ParameterContainer parameters) { EnvelopeDocument request = aSesRequest() .addSoapAction(SOAP_ACTION_NOTIFY_REQUEST) .addRecipient(getStringValueFor(NOTIFY_SES_URL, parameters)) .addFrom(W3C_ADDRESSING_ROLE_ANONYMOUS) .addMessageId() .build(); Body body = request.getEnvelope().getBody(); XmlCursor cur = body.newCursor(); cur.toFirstContentToken(); cur.beginElement(WSN_B.createQNameFor("Notify")); cur.beginElement(WSN_B.createQNameFor("NotificationMessage")); cur.beginElement(WSN_B.createQNameFor("Topic")); cur.insertAttributeWithValue("Dialect", getStringValueFor(NOTIFY_TOPIC_DIALECT, parameters)); cur.insertChars("@TOPIC_REPLACER@"); cur.toNextToken(); cur.beginElement(WSN_B.createQNameFor("Message")); cur.insertChars("@MSG_REPLACER@"); cur.dispose(); String toReplace = request.xmlText(new XmlOptions().setSavePrettyPrint()); String topic = getStringValueFor(NOTIFY_TOPIC, parameters); String xmlMessage = getStringValueFor(NOTIFY_XML_MESSAGE, parameters); return toReplace.replaceAll("@TOPIC_REPLACER@", topic).replaceAll("@MSG_REPLACER@", xmlMessage); }
@Deprecated public String buildUnsubscribeRequestLegacy(ParameterContainer parameters){ EnvelopeDocument request = aSesRequest() .addSoapAction(SOAP_ACTION_DESTROY_REQUEST) .addRecipient(getStringValueFor(UNSUBSCRIBE_SES_URL, parameters)) .addFrom(getFromAddress(W3C_ADDRESSING_ROLE_ANONYMOUS, parameters)) .addMessageId() .build(); Header soapHeader = request.getEnvelope().getHeader(); XmlCursor headerXmlCursor = soapHeader.newCursor(); headerXmlCursor.toLastChild(); headerXmlCursor.beginElement(new QName(N52_SES_RESOURCE_ID_NAMESPACE, "ResourceId", "muse-wsa")); headerXmlCursor.insertAttributeWithValue(WSA.createQNameFor("IsReferenceParameter"), "true"); headerXmlCursor.insertChars(getStringValueFor(UNSUBSCRIBE_REFERENCE, parameters)); headerXmlCursor.dispose(); XmlObject body = request.getEnvelope().getBody(); XmlCursor xmlBodyCursor = body.newCursor(); xmlBodyCursor = body.newCursor(); xmlBodyCursor.toFirstContentToken(); xmlBodyCursor.beginElement(WSN_B.createQNameFor("Destroy")); xmlBodyCursor.dispose(); return request.xmlText(); }
@Override public String buildDestroyRegistrationRequest( ParameterContainer parameters) throws OXFException { EnvelopeDocument request = aSesRequest() .addSoapAction(SOAP_ACTION_DESTROY_REGISTRATION_REQUEST) .addRecipient(getStringValueFor(DESTROY_REGISTRATION_SES_URL, parameters)) .addFrom(getFromAddress(W3C_ADDRESSING_ROLE_ANONYMOUS, parameters)) .addMessageId() .build(); Header soapHeader = request.getEnvelope().getHeader(); XmlCursor headerXmlCursor = soapHeader.newCursor(); headerXmlCursor.toLastChild(); String resourceId = getStringValueFor(DESTROY_REGISTRATION_REFERENCE, parameters); if (resourceId != null) { headerXmlCursor.beginElement(new QName(N52_SES_RESOURCE_ID_NAMESPACE, "ResourceId", "muse-wsa")); headerXmlCursor.insertAttributeWithValue(WSA.createQNameFor("IsReferenceParameter"), "true"); headerXmlCursor.insertChars(resourceId); } headerXmlCursor.dispose(); XmlObject body = request.getEnvelope().getBody(); DestroyRegistrationDocument destroyDoc = DestroyRegistrationDocument.Factory.newInstance(); destroyDoc.addNewDestroyRegistration(); body.set(destroyDoc); return request.xmlText(new XmlOptions().setSavePrettyPrint()); }