XSLT: Colon in attribute name in source XML

2019-07-25 14:41发布

问题:

I am trying to transform the android xml into Plist but i am facing the issue because the Android XML contains COLONS in the attribute names as follows:

  <PreferenceCategory android_title="Identity" >
        <EditTextPreference
            android:key="systemname"
            android_title="System Name" />
  </PreferenceCategory>

So when i try to read the attribute value using XSLT it gives the following error:

XPath evaluation returned no result.

I am bit new to XSLT, So can any one help me reading the attribute value which have colon in their names as mentioned above.

回答1:

Please read about XML Namespaces, a good starting point can be XML Namespaces tutorial on w3schools.com to know about the usage of "colons".

You could read the MSDN article about XML Namespaces and How They Affect XPath and XSLT to know more.



回答2:

I managed by using the exclude-result-prefixes attribute inside in XSLT. My stylesheet tag looked like below.

 <xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:android="http://schemas.android.com/apk/res/android"
 exclude-result-prefixes="android">

exclude-result-prefixes attribute is used if you want to exclude any namespace during compile time.



标签: android xml xslt