Jorg Heymans wrote:

Is there any particular reason why you want to implement this as a transformer? A stylesheet seems to be easier in this case IMHO.

I talked to Han some days ago, this transformer is just an example to get started.

> If you extend abstractdomtransformer you have access to the Document
> instance, but i don't know if that makes your problem any easier.

This is a good idea. It would make it easier, but slower
(depending on the processing - I don't know if this is
important for your application).

If you want to use SAX, you could do the following:

(1) A method for each element:

if (localName.equals(ELEMENT_ADDRESS)) {
    startElementAddress(...)
}
else if (localName.equals(ELEMENT_NAME)) {
    startElementName(...)
}
else if ...


(2) You could implement a set of handlers (ContentHandler or a simplier interface) and register them for the element names:

public void startElement(String namespaceURI, String localName,
    String qualifiedName, Attributes attributes) {
    handlers(localName).startElement(...);
}

public void endElement(String namespaceURI, String localName,
    String qualifiedName) {
    handlers(localName).endElement(...);
}

HTH,
-- Andreas


Jorg


Han Jon Theus wrote:

Hello
I just implemented a simple transformer with the start method below:

public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes)
throws SAXException {
String newLocalName = localName;
String newQualifiedName = qualifiedName;
//System.out.println(localName);
if (localName.equals(ELEMENT_ADDRESS)) {
newLocalName = "nickname";
String[] parts = qualifiedName.split(":");
if (parts.length == 2) {
newQualifiedName = parts[0] + ":" + newLocalName;
}
else
{
newQualifiedName = newLocalName; }
}
super.startElement(namespaceURI, newLocalName, newQualifiedName, attributes);
}


The transformer changes the local name "firstname" into "nickname". I would like to extend this transformer: it should be able to rename all xml tags. do i have to program a loop? do i have to implement multiple startElement()-methodes ?

Thx for you help

Han J. Theus-Student



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to