Hi.

after Cocoon recently upgraded to D9 (?) extension functions seem not
to be able to read a supplied NodeList anymore, i.e. the node list
seems empty. D8 works well.

this is the xsl:

      <!-- ... -->
      <!-- Generate matchers which implements CodeFactory -->
      <xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher">
        <xsl:call-template name="line-number"/>
        <xsl:variable name="src">
          <xsl:value-of select="@src"/>
        </xsl:variable>
        <xsl:if test="XSLTFactoryLoader:isFactory($factory-loader, string($src))">
          <xsl:variable name="name" select="@name"/>
          <xsl:variable name="type" select="translate(@name, '- ', '__')"/>
          <xsl:variable name="default" select="@name = ../@default"/>
          <xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
          private Map <xsl:value-of select="$type"/>Match (<xsl:value-of 
select="XSLTFactoryLoader:getParameterSource($factory-loader, string($src),$config)"/> 
pattern, Map objectModel, Parameters parameters) {
            <xsl:value-of select="XSLTFactoryLoader:getMethodSource($factory-loader, 
string($src),$config)"/>
          }
          <!-- ... -->

this is the code that looks at the config parameter:

    public String getMethodSource(String className, NodeList conf) throws 
ClassNotFoundException, InstantiationException,
        IllegalAccessException, Exception {

        //...

        int count = conf.getLength();
        for(int k = 0; k < count;k++) {
            Node node = conf.item(k);
            if (node.getNodeName() != null && 
                node.getNodeName().equals("parameter-name")) 
            {
                Node textNode = node.getFirstChild();
                if (textNode != null) {
                    parameterName = textNode.getNodeValue().trim();
                }
            }

       //...

this is the xml (the descendant axis of <map:matcher> is selected
above and passed as argument)

   <!-- ... -->
   <map:matcher name="referer-match" 
src="org.apache.cocoon.matching.WildcardHeaderMatcherFactory">
      <parameter-name>referer</parameter-name>
   </map:matcher>
   <!-- ... -->

Interestingly enough, I am not able to print out the configuration
info with D8, D9 nor D10 using this code

    public void dumpConfig(NodeList conf)
    { // dump config
        if (conf != null) {
            for (int i=0; i<conf.getLength(); i++) {
                Node node = conf.item(i);
                if (node!=null) {
                    if (node.hasChildNodes()){
                        getLogger().debug("<"+node.getNodeName()+">");
                        try {
                            this.dumpConfig(node.getChildNodes());
                        } catch (Exception e) {
                            getLogger().debug(e.toString()+e.getMessage());
                        }
                        getLogger().debug("</>");
                    } else {
                        getLogger().debug("<"+node.getNodeName()+"/>");
                    }
                }
            }
        }
    }
 
This code causes an org.apache.xml.dtm.DTMDOMException when
getChildNodes() is called....

Comment "getChildNodes()" returns the following (D8):

 <#document>
 </>
 <map:matcher>
 </>
 <#text/>
 <parameter-name>
 </>
 <#text/>
 <#text/>

Using D10 prints:

 <#document>
 </>

>From that it appears that D8 flattens the structure and D10
doesn't. It looks more reasonable to keep the tree structure here. But
why does getChildNodes() throw an exception and how could I make this
work again?

As I'm not subscribed to this list, it would be nice if you could CC
answers to me.

        Chris.

-- 
C h r i s t i a n       H a u l
[EMAIL PROTECTED]
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

Reply via email to