1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
30 import com.sun.xml.internal.xsom.parser.AnnotationParser;
31 import com.sun.xml.internal.xsom.parser.AnnotationParserFactory;
32 import javax.xml.XMLConstants;
33 import org.w3c.dom.Document;
34 import org.w3c.dom.Element;
35 import org.w3c.dom.Node;
36 import org.xml.sax.ContentHandler;
37 import org.xml.sax.EntityResolver;
38 import org.xml.sax.ErrorHandler;
39
40 import javax.xml.transform.TransformerConfigurationException;
41 import javax.xml.transform.dom.DOMResult;
42 import javax.xml.transform.sax.SAXTransformerFactory;
43 import javax.xml.transform.sax.TransformerHandler;
44
45 /**
46 * {@link AnnotationParserFactory} that parses annotations into a W3C DOM.
47 *
48 * <p>
49 * If you use this parser factory, you'll get {@link Element} that represents
50 * <xs:annotation> from {@link XSAnnotation#getAnnotation()}.
51 *
52 * <p>
53 * When multiple <xs:annotation>s are found for the given schema component,
54 * you'll see all <xs:appinfo>s and <xs:documentation>s combined under
55 * one <xs:annotation> element.
56 *
57 * @author Kohsuke Kawaguchi
58 */
59 public class DomAnnotationParserFactory implements AnnotationParserFactory {
60
61 public AnnotationParser create() {
62 return new AnnotationParserImpl();
63 }
64
65 public AnnotationParser create(boolean disableSecureProcessing) {
66 return new AnnotationParserImpl(disableSecureProcessing);
67 }
68
69 private static final ContextClassloaderLocal<SAXTransformerFactory> stf = new ContextClassloaderLocal<SAXTransformerFactory>() {
70 @Override
71 protected SAXTransformerFactory initialValue() throws Exception {
72 return (SAXTransformerFactory) SAXTransformerFactory.newInstance();
73 }
74 };
75
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
30 import com.sun.xml.internal.xsom.parser.AnnotationParser;
31 import com.sun.xml.internal.xsom.parser.AnnotationParserFactory;
32 import javax.xml.XMLConstants;
33 import org.w3c.dom.Document;
34 import org.w3c.dom.Element;
35 import org.w3c.dom.Node;
36 import org.xml.sax.ContentHandler;
37 import org.xml.sax.EntityResolver;
38 import org.xml.sax.ErrorHandler;
39
40 import javax.xml.transform.TransformerConfigurationException;
41 import javax.xml.transform.dom.DOMResult;
42 import javax.xml.transform.sax.SAXTransformerFactory;
43 import javax.xml.transform.sax.TransformerHandler;
44
45 /**
46 * {@link AnnotationParserFactory} that parses annotations into a W3C DOM.
47 *
48 * <p>
49 * If you use this parser factory, you'll get {@link Element} that represents
50 * {@code <xs:annotation>} from {@link XSAnnotation#getAnnotation()}.
51 *
52 * <p>
53 * When multiple {@code <xs:annotation>s} are found for the given schema component,
54 * you'll see all {@code <xs:appinfo>s} and {@code <xs:documentation>s} combined under
55 * one {@code <xs:annotation>} element.
56 *
57 * @author Kohsuke Kawaguchi
58 */
59 public class DomAnnotationParserFactory implements AnnotationParserFactory {
60
61 public AnnotationParser create() {
62 return new AnnotationParserImpl();
63 }
64
65 public AnnotationParser create(boolean disableSecureProcessing) {
66 return new AnnotationParserImpl(disableSecureProcessing);
67 }
68
69 private static final ContextClassloaderLocal<SAXTransformerFactory> stf = new ContextClassloaderLocal<SAXTransformerFactory>() {
70 @Override
71 protected SAXTransformerFactory initialValue() throws Exception {
72 return (SAXTransformerFactory) SAXTransformerFactory.newInstance();
73 }
74 };
75
|