xref: /AOO41X/main/wizards/com/sun/star/wizards/common/XMLHelper.java (revision a1b4a26b27259a85a9821d1e8083147f257d71ca)
1*a1b4a26bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*a1b4a26bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*a1b4a26bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*a1b4a26bSAndrew Rist  * distributed with this work for additional information
6*a1b4a26bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*a1b4a26bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*a1b4a26bSAndrew Rist  * "License"); you may not use this file except in compliance
9*a1b4a26bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*a1b4a26bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*a1b4a26bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*a1b4a26bSAndrew Rist  * software distributed under the License is distributed on an
15*a1b4a26bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*a1b4a26bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*a1b4a26bSAndrew Rist  * specific language governing permissions and limitations
18*a1b4a26bSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*a1b4a26bSAndrew Rist  *************************************************************/
21*a1b4a26bSAndrew Rist 
22*a1b4a26bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir /*
25cdf0e10cSrcweir  * XMLHelper.java
26cdf0e10cSrcweir  *
27cdf0e10cSrcweir  * Created on 30. September 2003, 15:38
28cdf0e10cSrcweir  */
29cdf0e10cSrcweir package com.sun.star.wizards.common;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir import org.w3c.dom.*;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /**
34cdf0e10cSrcweir  *
35cdf0e10cSrcweir  * @author  rpiterman
36cdf0e10cSrcweir  */
37cdf0e10cSrcweir public class XMLHelper
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 
addElement(Node parent, String name, String[] attNames, String[] attValues)40cdf0e10cSrcweir     public static Node addElement(Node parent, String name, String[] attNames, String[] attValues)
41cdf0e10cSrcweir     {
42cdf0e10cSrcweir         Document doc = parent.getOwnerDocument();
43cdf0e10cSrcweir         if (doc == null)
44cdf0e10cSrcweir         {
45cdf0e10cSrcweir             doc = (Document) parent;
46cdf0e10cSrcweir         }
47cdf0e10cSrcweir         Element e = doc.createElement(name);
48cdf0e10cSrcweir         for (int i = 0; i < attNames.length; i++)
49cdf0e10cSrcweir         {
50cdf0e10cSrcweir             if (attValues[i] != null && (!attValues[i].equals(PropertyNames.EMPTY_STRING)))
51cdf0e10cSrcweir             {
52cdf0e10cSrcweir                 e.setAttribute(attNames[i], attValues[i]);
53cdf0e10cSrcweir             }
54cdf0e10cSrcweir         }
55cdf0e10cSrcweir         parent.appendChild(e);
56cdf0e10cSrcweir         return e;
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir 
addElement(Node parent, String name, String attNames, String attValues)59cdf0e10cSrcweir     public static Node addElement(Node parent, String name, String attNames, String attValues)
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         return addElement(parent, name, new String[]
62cdf0e10cSrcweir                 {
63cdf0e10cSrcweir                     attNames
64cdf0e10cSrcweir                 }, new String[]
65cdf0e10cSrcweir                 {
66cdf0e10cSrcweir                     attValues
67cdf0e10cSrcweir                 });
68cdf0e10cSrcweir     }
69cdf0e10cSrcweir }
70