I'm trying to get some information from XML with a XSLT. I'm facing an XML (from MediaInfo tool https://mediaarea.net/fr/MediaInfo) with various namespaces. I tried many solutions found here (and there is lot of posts about it), but I don't find the correct way to do it... I thik my problem is due to namespace. My XSL namespace is probably too much regarding what I want.
In my example below, I simplify XML, and I just try to get value of "Title"
Here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<MediaInfo
xmlns="https://mediaarea.net/mediainfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://mediaarea.net/mediainfo https://mediaarea.net/mediainfo/mediainfo_2_0.xsd"
version="2.0">
<creatingLibrary version="19.09" url="https://mediaarea.net/MediaInfo">MediaInfoLib</creatingLibrary>
<media ref="F:\media\audio\Madonna - Die Another Day.aif">
<track type="General">
<AudioCount>1</AudioCount>
<FileExtension>aif</FileExtension>
<Title>Die Another Day</Title>
<Album>American Life</Album>
<Track>1</Track>
<Performer>Madonna</Performer>
<Composer>Mirwais Ahmadzaï - Madonna</Composer>
<Genre>Pop</Genre>
<Comment>Die Another Day (soundtrack)</Comment>
</track>
<track type="Audio">
<Format>PCM</Format>
<Format_Settings_Endianness>Big</Format_Settings_Endianness>
<BitRate_Mode>CBR</BitRate_Mode>
<Channels>2</Channels>
<SamplingRate>48000</SamplingRate>
<BitDepth>24</BitDepth>
</track>
</media>
</MediaInfo>
and my XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="https://mediaarea.net/mediainfo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://mediaarea.net/mediainfo https://mediaarea.net/mediainfo/mediainfo_2_0.xsd">
<xsl:output method="xml" encoding="UTF-8" indent="yes" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:variable name="Title">
<xsl:value-of select="MediaInfo/media/track[@type='General']/Title"/>
</xsl:variable>
<xsl:element name="AUDIO" >
<xsl:element name="title">
<xsl:value-of select="$Title"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
my output is:
<AUDIO xmlns="https://mediaarea.net/mediainfo">
<title/>
</AUDIO>
and I'm looking for:
<AUDIO xmlns="https://mediaarea.net/mediainfo">
<title>Die Another Day</title>
</AUDIO>