[xsl] Simple XML -> XML transform problem, possibly namespace related

Subject: [xsl] Simple XML -> XML transform problem, possibly namespace related
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Sat, 15 May 2004 19:03:11 -0500
Hi all,

this one really has stumped me. I am trying to to do a simple XML to XML
transformation in which I'm only inserting two paths, but they do not
appear. Unfortunately, I absolutely cannot change the input XML since this
is a format for a so-called job file that the Helix Producer ActiveX control
expects. It worked all well with the Helix job file spec 1.0 but now with
the new Helix job spec v2.0, some things have changed, in particular the
aggregation of a few new namespaces. It may be that these are causing me the
problem.

I have the following simple XSL:

<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns="http://ns.real.com/tools/job.2.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
version="1.0">

	<xsl:output method="xml" indent="yes" encoding="Windows-1252" />

	<xsl:param name="strSourceFileNamePath" />
	<xsl:param name="strDestinationFileNamePath" />

	<xsl:template match="node()|@*">
		<xsl:copy>
			<xsl:apply-templates select="node()|@*"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/job/inputs/input/filename" >
		<filename type="string"><xsl:value-of
select="$strSourceFileNamePath" /></filename>
	</xsl:template>

	<xsl:template
match="/job/parOutputs/output/destinations/destination/filename">
		<filename type="string"><xsl:value-of
select="$strDestinationFileNamePath" /></filename>
	</xsl:template>

</xsl:stylesheet>

in which everything is simply copied using a identity template, except for
two <filename> node elements that should receive their respective paths from
the variables $strSourceFileNamePath and $strDestinationFileNamePath. But
they are never processed. Note that these two node elements have the same
name but their location is different, that's why I specified their resp.
complete path.

If I run the above XSL on my XML (see below), the templates are ignored. I
suspect it has to do something with the namespace for xsi:, but I'm not
sure. If I delete the namespaces added to the <job> element in the XML, and
remove any related xsl: attributes, it works; but as said, I cannot change
the XML, so I'll need to sort it out in my XSL.

Thanx in advance for any help. And sorry for the long message, but I only
want to be as complete as possible.

The unchangable XML is:

<?xml version="1.0" encoding="UTF-8"?>
<job xmlns="http://ns.real.com/tools/job.2.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://ns.real.com/tools/job.2.0
http://ns.real.com/tools/job.2.0.xsd";>
  <enableTwoPass type="bool">false</enableTwoPass>
  <clipInfo>
    <entry>
      <name>Copyright</name>
      <value type="string">(C) 2004</value>
    </entry>
  </clipInfo>
  <inputs>
    <input xsi:type="avFileInput">
      <filename type="string"></filename>
    </input>
  </inputs>
  <parOutputs>
    <output>
      <destinations>
        <destination xsi:type="fileDestination">
          <name type="string">FileOutput</name>
          <filename type="string"></filename>
        </destination>
      </destinations>
      <mediaProfile>
        <audienceRefs>
          <audienceRef>384k DSL or Cable</audienceRef>
        </audienceRefs>
      </mediaProfile>
    </output>
  </parOutputs>
  <audiences>
    <audience xmlns="http://ns.real.com/tools/audience.2.0";>
      <name type="string">384k DSL or Cable</name>
      <avgBitrate type="uint">350000</avgBitrate>
      <maxBitrate type="uint">700000</maxBitrate>
      <streams>
        <stream xsi:type="videoStream">
          <pluginName type="string">rn-videocodec-realvideo</pluginName>
          <codecName type="string">rv10</codecName>
          <encodingType type="string">cbr</encodingType>
          <encodingComplexity type="string">high</encodingComplexity>
          <quality type="uint">77</quality>
          <maxStartupLatency type="double">4</maxStartupLatency>
          <maxFrameRate type="double">30</maxFrameRate>
          <maxKeyFrameInterval type="double">10</maxKeyFrameInterval>
          <enableLossProtection type="bool">false</enableLossProtection>
        </stream>
        <stream xsi:type="audioStream">
          <pluginName type="string">rn-audiocodec-realaudio</pluginName>
          <codecName type="string">cook</codecName>
          <codecFlavor type="uint">14</codecFlavor>
          <encodingComplexity type="string">high</encodingComplexity>
          <streamContext type="bag">
            <presentationType type="string">audio-video</presentationType>
            <audioMode type="string">voice</audioMode>
          </streamContext>
        </stream>
      </streams>
    </audience>
  </audiences>
</job>
 
Cheers,
<prs/>

Current Thread