diff --git a/src/saml2/saml.py b/src/saml2/saml.py
index <HASH>..<HASH> 100644
--- a/src/saml2/saml.py
+++ b/src/saml2/saml.py
@@ -166,11 +166,16 @@ class AttributeValueBase(SamlBase):
 
         try:
             self.extension_attributes[XSI_TYPE] = typ
-            self.extension_attributes['xmlns:xs'] = XS_NAMESPACE
         except AttributeError:
-            self._extatt['xmlns:xs'] = XS_NAMESPACE
             self._extatt[XSI_TYPE] = typ
 
+        if typ.startswith('xs:'):
+            try:
+                self.extension_attributes['xmlns:xs'] = XS_NAMESPACE
+            except AttributeError:
+                self._extatt['xmlns:xs'] = XS_NAMESPACE
+
+
     def get_type(self):
         try:
             return self.extension_attributes[XSI_TYPE]
It's cleaner to conditionally add this attribute

As per @jgehrcke's comment