cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@yahoo.com>
Subject Re: [C2] [Xalan2] extract "xmlns:" tags from XSL
Date Thu, 05 Oct 2000 12:37:44 GMT
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