cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Boag/CAM/Lotus" <Scott_B...@lotus.com>
Subject Re: [C2] [Xalan2] extract "xmlns:" tags from XSL
Date Thu, 05 Oct 2000 13:49:28 GMT

Hmm... you want to go through the TrAX interfaces for this?

Do you need these at parse time, or way after the fact?

-scott




                                                                                         
                         
                    Davanum                                                              
                         
                    Srinivas             To:     cocoon-dev@xml.apache.org               
                         
                    <dims@yahoo.c        cc:     Scott_Boag@lotus.com, xalan-dev@xml.apache.org
                   
                    om>                  Subject:     Re: [C2] [Xalan2] extract "xmlns:"
tags from XSL             
                                                                                         
                         
                    10/05/2000                                                           
                         
                    08:37 AM                                                             
                         
                    Please                                                               
                         
                    respond to                                                           
                         
                    xalan-dev                                                            
                         
                                                                                         
                         
                                                                                         
                         



Scott,

We need to get a list of xmlns attributes that are specified in the .XSL
files. I don't see a easy
way to extract it from a trax.Templates instance. I definitely know that
trax.Templates is nothing
but a org.apache.xalan.templates.StylesheetRoot. But am unable to get the
info. Here's the code
that i tried. It throws exception in getDocumentElement. Please let us know
how to do this.

Thanks,
dims

--------------------------------------------------------
Vector vector = new Vector();
StylesheetRoot stylesheet = (StylesheetRoot)templates;
int n = stylesheet.getGlobalImportCount();
for(int j = 0; j < n; j++)
{
  Stylesheet imported = stylesheet.getGlobalImport(j);
  Element element = imported.getDocumentElement();
  NamedNodeMap map = element.getAttributes();
  int attrCount = map.getLength();
  for (int i = 0; i < attrCount; i++)
  {
    Attr attr = (Attr) map.item(i);
    String attrName = attr.getName();
    if (
     !attrName.equals("xmlns:xsl") &&
         (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
    ) {
      String[] pair = new String[2];
      pair[0] = attrName;
      pair[1] = attr.getValue();
      vector.addElement(pair);
    }
  }
}
--------------------------------------------------------


__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/





Mime
View raw message