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