You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Davanum Srinivas <di...@yahoo.com> on 2000/10/05 14:37:44 UTC
Re: [C2] [Xalan2] extract "xmlns:" tags from XSL
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/