Package net.sf.saxon.event

## Class PIGrabber

- java.lang.Object
- - net.sf.saxon.event.SequenceReceiver
  - - net.sf.saxon.event.ProxyReceiver
    - - net.sf.saxon.event.PIGrabber

- All Implemented Interfaces:
    `javax.xml.transform.Result`, `Receiver`

      public class PIGrabber
      extends ProxyReceiver

  The `PIGrabber` class is a `ProxyReceiver` that looks for `xml-stylesheet` processing instructions and tests whether they match specified criteria; for those that do, it creates a `Source` object referring to the relevant stylesheet

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.event.ProxyReceiver

      `nextReceiver`

    - ### Fields inherited from class net.sf.saxon.event.SequenceReceiver

      `pipelineConfiguration, previousAtomic, systemId`

    - ### Fields inherited from interface javax.xml.transform.Result

      `PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PIGrabber​(Receiver next)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `javax.xml.transform.Source[]` | `getAssociatedStylesheets()` | Return list of stylesheets that matched, as an array of Source objects
    `boolean` | `isTerminated()` | Determine whether the parse terminated because the first start element tag was found
    `void` | `processingInstruction​(java.lang.String target, java.lang.CharSequence data, Location locationId, int properties)` | Handle xml-stylesheet PI
    `void` | `setBaseURI​(java.lang.String uri)` | Set the base URI
    `void` | `setCriteria​(java.lang.String media, java.lang.String title)` | Define the matching criteria
    `void` | `setFactory​(Configuration config)` |
    `void` | `setURIResolver​(javax.xml.transform.URIResolver resolver)` | Set the URI resolver to be used for the href attribute
    `void` | `startElement​(NodeName elemName, SchemaType type, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties)` | Abort the parse when the first start element tag is found

    - ### Methods inherited from class net.sf.saxon.event.ProxyReceiver

      `append, characters, close, comment, endDocument, endElement, getNamePool, getNextReceiver, open, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, startDocument, usesTypeAnnotations`

    - ### Methods inherited from class net.sf.saxon.event.SequenceReceiver

      `append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getPipelineConfiguration, getSystemId, handlesAppend`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PIGrabber

          public PIGrabber​(Receiver next)

  - ### Method Detail

    - #### setFactory

          public void setFactory​(Configuration config)

    - #### setCriteria

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

      Define the matching criteria
      Parameters:
        `media` - the required media. Note that Saxon does not implement the complex CSS3-based syntax for media queries. By default, the media value is simply ignored. An algorithm for comparing the requested media with the declared media can be defined using the method `Configuration.setMediaQueryEvaluator(Comparator)`.
        `title` - the required 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 elemName,
                                   SchemaType type,
                                   AttributeMap attributes,
                                   NamespaceMap namespaces,
                                   Location location,
                                   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:
        `elemName` - the name of the element.
        `type` - the type annotation of the element.
        `attributes` - the attributes of this element
        `namespaces` - the in-scope namespaces of this element: generally this is all the in-scope namespaces, without relying on inheriting namespaces from parent elements
        `location` - an object providing information about the module, line, and column where the node originated
        `properties` - bit-significant properties of the element node. If there are no relevant properties, zero is supplied. The definitions of the bits are in class `ReceiverOption`
      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,
                                            Location 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` - provides information such as line number and system ID.
        `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`