Class PIGrabber

  • All Implemented Interfaces:
    javax.xml.transform.Result, Receiver

    public class PIGrabber
    extends ProxyReceiver
    The PIGrabber class is a Receiver that looks for xml-stylesheet processing instructions and tests whether they match specified criteria; for those that do, it creates an InputSource object referring to the relevant stylesheet
    Author:
    Michael H. Kay
    • Constructor Detail

      • PIGrabber

        public PIGrabber​(Receiver next)
    • Method Detail

      • setCriteria

        public void setCriteria​(java.lang.String media,
                                java.lang.String title)
      • setBaseURI

        public void setBaseURI​(java.lang.String uri)
        Set the base URI
        Parameters:
        uri - the base URI
      • setURIResolver

        public void setURIResolver​(javax.xml.transform.URIResolver resolver)
        Set the URI resolver to be used for the href attribute
        Parameters:
        resolver - the URI resolver
      • startElement

        public void startElement​(NodeName namecode,
                                 SchemaType typecode,
                                 int locationId,
                                 int properties)
                          throws XPathException
        Abort the parse when the first start element tag is found
        Specified by:
        startElement in interface Receiver
        Overrides:
        startElement in class ProxyReceiver
        Parameters:
        namecode - integer code identifying the name of the element within the name pool.
        typecode - integer code identifying the element's type within the name pool.
        locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
        properties - properties of the element node
        Throws:
        XPathException - if an error occurs
      • isTerminated

        public boolean isTerminated()
        Determine whether the parse terminated because the first start element tag was found
        Returns:
        true if the parse was terminated when the document element was encountered (as distinct from being terminated because of some exception condition, for example a parse error)
      • processingInstruction

        public void processingInstruction​(java.lang.String target,
                                          java.lang.CharSequence data,
                                          int locationId,
                                          int properties)
                                   throws XPathException
        Handle xml-stylesheet PI
        Specified by:
        processingInstruction in interface Receiver
        Overrides:
        processingInstruction in class ProxyReceiver
        Parameters:
        target - The PI name. This must be a legal name (it will not be checked).
        data - The data portion of the processing instruction
        locationId - an integer which can be interpreted using a LocationProvider to return information such as line number and system ID. If no location information is available, the value zero is supplied.
        properties - Additional information about the PI.
        Throws:
        XPathException - if an error occurs
      • getAssociatedStylesheets

        public javax.xml.transform.Source[] getAssociatedStylesheets()
                                                              throws javax.xml.transform.TransformerException
        Return list of stylesheets that matched, as an array of Source objects
        Returns:
        null if there were no matching stylesheets.
        Throws:
        XPathException - if a URI cannot be resolved
        javax.xml.transform.TransformerException