src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/StylesheetPIHandler.java
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
equal deleted inserted replaced
47358:d07d5f7cab35 47359:e1a6c0168741
     1 /*
     1 /*
     2  * reserved comment block
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT REMOVE OR ALTER!
     3  * @LastModified: Oct 2017
     4  */
     4  */
     5 /*
     5 /*
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  * contributor license agreements.  See the NOTICE file distributed with
     7  * contributor license agreements.  See the NOTICE file distributed with
     8  * this work for additional information regarding copyright ownership.
     8  * this work for additional information regarding copyright ownership.
    19  * limitations under the License.
    19  * limitations under the License.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.xml.internal.utils;
    22 package com.sun.org.apache.xml.internal.utils;
    23 
    23 
       
    24 import java.util.ArrayList;
       
    25 import java.util.List;
    24 import java.util.StringTokenizer;
    26 import java.util.StringTokenizer;
    25 import java.util.Vector;
       
    26 
       
    27 import javax.xml.transform.Source;
    27 import javax.xml.transform.Source;
    28 import javax.xml.transform.TransformerException;
    28 import javax.xml.transform.TransformerException;
    29 import javax.xml.transform.URIResolver;
    29 import javax.xml.transform.URIResolver;
    30 import javax.xml.transform.sax.SAXSource;
    30 import javax.xml.transform.sax.SAXSource;
    31 
       
    32 import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
       
    33 
       
    34 import org.xml.sax.Attributes;
    31 import org.xml.sax.Attributes;
    35 import org.xml.sax.InputSource;
    32 import org.xml.sax.InputSource;
    36 import org.xml.sax.helpers.DefaultHandler;
    33 import org.xml.sax.helpers.DefaultHandler;
    37 
    34 
    38 /**
    35 /**
    39  * Search for the xml-stylesheet processing instructions in an XML document.
    36  * Search for the xml-stylesheet processing instructions in an XML document.
    40  * @see <a href="http://www.w3.org/TR/xml-stylesheet/">Associating Style Sheets with XML documents, Version 1.0</a>
    37  * @see <a href="http://www.w3.org/TR/xml-stylesheet/">
       
    38  * Associating Style Sheets with XML documents, Version 1.0</a>
    41  */
    39  */
    42 public class StylesheetPIHandler extends DefaultHandler
    40 public class StylesheetPIHandler extends DefaultHandler
    43 {
    41 {
    44   /** The baseID of the document being processed.  */
    42   /** The baseID of the document being processed.  */
    45   String m_baseID;
    43   String m_baseID;
    52 
    50 
    53   /** The desired character set criteria.   */
    51   /** The desired character set criteria.   */
    54   String m_charset;
    52   String m_charset;
    55 
    53 
    56   /** A list of SAXSource objects that match the criteria.  */
    54   /** A list of SAXSource objects that match the criteria.  */
    57   Vector m_stylesheets = new Vector();
    55   List<Source> m_stylesheets = new ArrayList<>();
    58 
    56 
    59   // Add code to use a URIResolver. Patch from Dmitri Ilyin.
    57   // Add code to use a URIResolver. Patch from Dmitri Ilyin.
    60 
    58 
    61   /**
    59   /**
    62    * The object that implements the URIResolver interface,
    60    * The object that implements the URIResolver interface,
   118 
   116 
   119     int sz = m_stylesheets.size();
   117     int sz = m_stylesheets.size();
   120 
   118 
   121     if (sz > 0)
   119     if (sz > 0)
   122     {
   120     {
   123       Source source = (Source) m_stylesheets.elementAt(sz-1);
   121       Source source = m_stylesheets.get(sz-1);
   124       return source;
   122       return source;
   125     }
   123     }
   126     else
   124     else
   127       return null;
   125       return null;
   128   }
   126   }
   134    * @param data The processing instruction data, or null if
   132    * @param data The processing instruction data, or null if
   135    *             none is supplied.
   133    *             none is supplied.
   136    * @throws org.xml.sax.SAXException Any SAX exception, possibly
   134    * @throws org.xml.sax.SAXException Any SAX exception, possibly
   137    *            wrapping another exception.
   135    *            wrapping another exception.
   138    * @see org.xml.sax.ContentHandler#processingInstruction
   136    * @see org.xml.sax.ContentHandler#processingInstruction
   139    * @see <a href="http://www.w3.org/TR/xml-stylesheet/">Associating Style Sheets with XML documents, Version 1.0</a>
   137    * @see <a href="http://www.w3.org/TR/xml-stylesheet/">
       
   138    * Associating Style Sheets with XML documents, Version 1.0</a>
   140    */
   139    */
   141   public void processingInstruction(String target, String data)
   140   public void processingInstruction(String target, String data)
   142           throws org.xml.sax.SAXException
   141           throws org.xml.sax.SAXException
   143   {
   142   {
   144 
   143 
   297           }
   296           }
   298           else
   297           else
   299             return;
   298             return;
   300         }
   299         }
   301 
   300 
   302         m_stylesheets.addElement(source);
   301         m_stylesheets.add(source);
   303       }
   302       }
   304     }
   303     }
   305   }
   304   }
   306 
   305 
   307 
   306