{
  void doApply(Stylesheet stylesheet, QName mode,             Node context, int pos, int len,             Node parent, Node nextSibling)    throws TransformerException  {    Document doc = (parent instanceof Document) ? (Document) parent :      parent.getOwnerDocument();    // Create a document fragment to hold the name    DocumentFragment fragment = doc.createDocumentFragment();    // Apply name to the fragment    name.apply(stylesheet, mode,               context, pos, len,               fragment, null);    // Use XPath string-value of fragment    String nameValue = Expr.stringValue(fragment);    String namespaceValue = null;    if (namespace != null)      {        // Create a document fragment to hold the namespace        fragment = doc.createDocumentFragment();        // Apply namespace to the fragment        namespace.apply(stylesheet, mode,                        context, pos, len,                        fragment, null);        // Use XPath string-value of fragment        namespaceValue = Expr.stringValue(fragment);        if (namespaceValue.length() == 0)          {            namespaceValue = null;          }      }        String prefix = getPrefix(nameValue);    if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix))      {        int ci = nameValue.indexOf(':');        nameValue = nameValue.substring(ci + 1);      }    else      {        // Namespace aliasing        if (prefix == null)          {            prefix = "#default";          }        String resultPrefix =          (String) stylesheet.namespaceAliases.get(prefix);        if (resultPrefix != null)          {            if ("#default".equals(resultPrefix))              {                resultPrefix = null;              }            namespaceValue = source.lookupNamespaceURI(resultPrefix);          }        if (prefix == "#default")          {            prefix = null;          }        // Look up ordinary namespace for this prefix        if (namespaceValue == null)          {            if (XMLConstants.XML_NS_PREFIX.equals(prefix))              {                namespaceValue = XMLConstants.XML_NS_URI;              }            else              {                // Resolve namespace for this prefix                namespaceValue = source.lookupNamespaceURI(prefix);              }          }        /*if (prefix == null)          {            // Resolve prefix for this namespace            prefix = parent.lookupPrefix(namespaceValue);            if (prefix != null)              {                nameValue = prefix + ":" + nameValue;              }          }*/      }    // Create element    Element element = (namespaceValue != null) ?      doc.createElementNS(namespaceValue, nameValue) :          doc.createElement(nameValue);    if (nextSibling != null)      {        parent.insertBefore(element, nextSibling);      }    else      {        parent.appendChild(element);      }    stylesheet.addNamespaceNodes(source, element, doc,                                 elementExcludeResultPrefixes);    if (uas != null)      {        StringTokenizer st = new StringTokenizer(uas, " ");        while (st.hasMoreTokens())          {            addAttributeSet(stylesheet, mode, context, pos, len,                            element, null, st.nextToken());          }      }    if (children != null)      {        children.apply(stylesheet, mode,                       context, pos, len,                       element, null);      }    if (next != null)      {        next.apply(stylesheet, mode,                   context, pos, len,                   parent, nextSibling);      }  }