Skip to main content

merging files: transformer not including elements from document() in xsl script

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2011-03-25

Hi Folks,
i wrote a xsl script merging to files:
1.) putting all the referenced elements in a variable (via a parameter who is passed into the scripted):

<xsl:param name="ForeignContentSource">Merge2.svg</xsl:param><br />
<xsl:variable name="mdodetails" select="document($ForeignContentSource)" />

2.) calling a copy-template for these referenced items:
2.1.) selecting the items when a special ID occurs
<xsl:template match="//svg:g[@id='graph1']"><br />
            <xsl:apply-templates select="$mdodetails//foreignObject"/><br />

2.2.) copying the items:
 <xsl:template match="@* | node()"  name="copy"><br />
        <xsl:copy><br />
            <xsl:apply-templates select="@* | node()"/><br />
        </xsl:copy><br />

When i execute this script with Oxygene (Saxon 8B, Saxon 6.5.5 or Xalan) everything works fine.
The Output is like:

&lt;svg&gt;&lt;g&gt;[...some copied elements from original inputfile...]&lt;importedObjectFromXmlDoc1/&gt;&lt;importedObjectFromXmlDoc2/&gt;&lt;importedObjectFromXmlDoc3/&gt; [...] &lt;/g&gt; &lt;/svg&gt;

But calling this script via JAXP leaves out all importedObjectFromXmlDoc-elements:
&lt;svg&gt;&lt;g&gt;[...some copied elements from original inputfile...]&lt;/g&gt; &lt;/svg&gt;

I implemented the URIResolver like this (seems to work, debugging gave me the right file):
class MergeUriResolver implements URIResolver 
public Source resolve(String href, String base)
throws TransformerException {
File loadingFile = new File(&quot;src\\parsing\\&quot;+href);
StreamSource ss = new StreamSource(loadingFile);
return ss;

and set up the UriResolver for the Transformator-Factory:
transFactory.setURIResolver(new MergeUriResolver());
Well, i have no idea, why Oxygene gives me the correct result, but JAXP does not.
Both files to be merged are SVG files. Help is pretty much appreciated.
Kind Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-03-25

ok, problem found. its a xml validation issue.
thread can be closed.