How to deal with presence or not of xml namespaces using xslt.

Posted by Mycol on Stack Overflow See other posts from Stack Overflow or by Mycol
Published on 2010-04-16T11:52:46Z Indexed on 2010/04/16 12:53 UTC
Read the original article Hit count: 305

Filed under:
|
|

I have some XML/TEI documents, and i'm writing an XSLT 2.0 to extract their content.

Almost all TEI documents has no namespace, but one has the default namespace (xmlns="http://www.tei-c.org/ns/1.0"). So all documents has the same aspect, with unqulified tags like <TEI> or <teiHeader>, but if I try to extract the content, all works with "non-namespaced-documents", but nothing (of course) is extracted from the namespaced-document.

So i used the attribute xpath-default-namespace="http://www.tei-c.org/ns/1.0" and now (of course) the only document working is the namespaced one.

I can't edit documents at all, so what I'm asking is if there's a way to change dynamically the xpath-default-namespace in order to make work xpaths like //teiHeader both with namespaced and non-namespaced documents

© Stack Overflow or respective owner

Related posts about namespaces

Related posts about xslt