// Try a bunch of really ugly stuff to find the fragment.
// What's the right way to do this?
// Create a XPath parser.
XPathParser parser = new XPathParser((ErrorListener)m_problemListener.getErrorHandler(), null);
XPathContext xpathContext = new XPathContext();
PrefixResolverDefault nsNode = new PrefixResolverDefault(fragBase); //xpathContext.getNamespaceContext();
NodeIterator nl = null;
// Create the XPath object.
try{
XPath xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
Compiler compiler = new Compiler();
// Parse the xpath
parser.initXPath(compiler, "id("+fragID+")", nsNode);
org.apache.xpath.objects.XObject xobj = xpath.execute(xpathContext, fragBase, nsNode);
nl = xobj.nodeset();
if(nl.nextNode() == null)
{
// xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@id='"+fragID+"']", fragBase, nsNode);
// Create the XPath object.
xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
// Parse the xpath
parser.initXPath(compiler, "//*[@id='"+fragID+"']", nsNode);
xobj = xpath.execute(xpathContext, fragBase, nsNode);
nl = xobj.nodeset();
if(nl.nextNode() == null)
{
// xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@name='"+fragID+"']", fragBase, nsNode);
// Create the XPath object.
xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
// Parse the xpath
parser.initXPath(compiler, "//*[@name='"+fragID+"']", nsNode);
xobj = xpath.execute(xpathContext, fragBase, nsNode);
nl = xobj.nodeset();
if(nl.nextNode() == null)
{
// Well, hell, maybe it's an XPath...
// xobj = Stylesheet.evalXPathStr(getExecContext(), fragID, fragBase, nsNode);
// Create the XPath object.
//((StylesheetHandler)( m_processor.getTemplatesBuilder())).getLocator()
xpath = new XPath(fragID, null, nsNode, XPath.MATCH);
// Parse the xpath
parser.initXPath(compiler, fragID, nsNode);
xobj = xpath.execute(xpathContext, fragBase, nsNode);
nl = xobj.nodeset();
}
}
}