title: XSLT- Pre Define NameSpace
body: <p>Hi I have an XML that upon each delivery has a different unique named Namespace that I cannot pre determine with standard processes.</p>
  
  <pre><code>&lt;ABC xmlns:this="urn:uuid:9b1f15a9-69de-11d2-b6bc-fcab70ff7331" version="1.1"&gt;
  &lt;Extensions&gt;
    &lt;Identification&gt;urn:uuid:9b1f15a9-69de-11d2-b6bc-fcab70ff7331&lt;/Identification&gt;
    &lt;Extension&gt;
      &lt;SrcPackage&gt;
          &lt;this:ABDList&gt;
            &lt;TaggedValue&gt;111&lt;/TaggedValue&gt;
          &lt;/this:ABDList&gt;
          &lt;this:SubBegin&gt;0&lt;/this:SubBegin&gt;
      &lt;/SrcPackage&gt;
      &lt;MatPackage&gt;
          &lt;this:ABDList&gt;
            &lt;TaggedValue&gt;222&lt;/TaggedValue&gt;
          &lt;/this:ABDList&gt;
          &lt;this:SubBegin&gt;1&lt;/this:SubBegin&gt;
      &lt;/MatPackage&gt;
      &lt;!-- Stuff --&gt;
    &lt;/Extention&gt;
  &lt;/Extentions&gt;
  &lt;/ABC&gt;
  </code></pre>
  
  <p>The Next XML delivered could be </p>
  
  <pre><code>&lt;ABC xmlns:this="urn:uuid:9b1FFae4-69de-11d2-b6bc-fcab70ff7331" version="1.1"&gt;
  &lt;Extensions&gt;
    &lt;Identification&gt;urn:uuid:9b1FFae4-69de-11d2-b6bc-fcab70ff7331&lt;/Identification&gt;
    &lt;Extension&gt;
      &lt;SrcPackage&gt;
          &lt;this:ABDList&gt;
            &lt;TaggedValue&gt;333&lt;/TaggedValue&gt;
          &lt;/this:ABDList&gt;
          &lt;this:SubBegin&gt;0&lt;/this:SubBegin&gt;
      &lt;/SrcPackage&gt;
      &lt;MatPackage&gt;
          &lt;this:ABDList&gt;
            &lt;TaggedValue&gt;444&lt;/TaggedValue&gt;
          &lt;/this:ABDList&gt;
          &lt;this:SubBegin&gt;1&lt;/this:SubBegin&gt;
      &lt;/MatPackage&gt;
      &lt;!-- Stuff --&gt;
    &lt;/Extention&gt;
  &lt;/Extentions&gt;
  &lt;/ABC&gt;
  </code></pre>
  
  <p>My current XSL stylesheet works on the first XML predefining the Namespace 
  But I am looking to find a way to re-define it later on. on the process. I have added a variable to pull the relevant uuid from the Identification element but am not sure how to integrate this. Using the below stylesheet to process any other XML results in false results. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0"
  
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:this="urn:uuid:9b1f15a9-69de-11d2-b6bc-fcab70ff7331"
  xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext"&gt;
  &lt;xsl:output method="xml" omit-xml-declaration="yes" indent="yes" /&gt;
  &lt;xsl:strip-space elements="*"/&gt;
  
  &lt;xsl:variable name="SelOpGroup" select="/ABC/Extensions/Identification"/&gt;
  
  &lt;!-- Pass thru  ---&gt;
  &lt;xsl:template match="@*|node()"&gt;
  &lt;xsl:copy&gt;
      &lt;xsl:apply-templates select="@*|node()"/&gt;
  &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/ABC/Extensions/SrcPackage&gt;
    &lt;xsl:copy&gt;
              &lt;this:ABDList&gt;
                  &lt;xsl:copy-of select ="this:ABDList/*"/&gt;
                  &lt;TaggedA&gt;888&lt;/TaggedA&gt;
              &lt;/this:ABDList&gt;
              &lt;this:SubBegin&gt;&lt;xsl:value-of select="somethingelse"/&gt; &lt;/this:SubBegin&gt;
    &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/ABC/Extensions/MatPackage&gt;
    &lt;xsl:copy&gt;
              &lt;this:ABDList&gt;
                  &lt;xsl:copy-of select ="this:ABDList/*"/&gt;
                  &lt;TaggedB&gt;999&lt;/TaggedB&gt;
              &lt;/this:ABDList &gt;
              &lt;this:SubBegin&gt;&lt;xsl:value-of select="somethingelse"/&gt; &lt;/this:SubBegin&gt;
    &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Expected Result</p>
  
  <pre><code>&lt;ABC xmlns:this="urn:uuid:9b1FFae4-69de-11d2-b6bc-fcab70ff7331" version="1.1"&gt;
  &lt;Extensions&gt;
    &lt;Identification&gt;urn:uuid:9b1FFae4-69de-11d2-b6bc-fcab70ff7331&lt;/Identification&gt;
    &lt;Extension&gt;
      &lt;SrcPackage&gt;
          &lt;this:ABDList&gt;
            &lt;TaggedValue&gt;333&lt;/TaggedValue&gt;
            &lt;TaggedA&gt;888&lt;/TaggedA&gt;
          &lt;/this:ABDList&gt;
          &lt;this:SubBegin&gt;a value&lt;/this:SubBegin&gt;
      &lt;/SrcPackage&gt;
      &lt;MatPackage&gt;
          &lt;this:ABDList&gt;
            &lt;TaggedValue&gt;444&lt;/TaggedValue&gt;
            &lt;TaggedB&gt;999&lt;/TaggedA&gt;
          &lt;/this:ABDList&gt;
          &lt;this:SubBegin&gt;a value&lt;/this:SubBegin&gt;
      &lt;/MatPackage&gt;
      &lt;!-- Stuff --&gt;
    &lt;/Extention&gt;
  &lt;/Extentions&gt;
  &lt;/ABC&gt;
  </code></pre>
  
  <p>Many thanks,
  Adrian</p>