Hi Monks

Please help me to resolve the issue here as I am trying to convert one XML file in one to another format via XML::LibXSLT module.

Input file for XSLT conversion :
<?xml version="1.0" encoding="utf-8"?> <File xmlns ="http://www.w3.org/2001/XMLSchema"> <DataDescrip> <ID>C01362023</ID> <Reference>702154</Reference> </DataDescrip> </File>
Output After XSLT Conversion:

<?xml version="1.0"?> C01362023 702154 <b>.xsl file used for Conversion</b> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" versi +on="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="File"> <Data xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsl:for-each select="DataDescrip"> <xsl:element name="Details"> <xsl:element name="ReferenceID"><xsl:value-of select="Reference"/></xs +l:element> </xsl:element> </xsl:for-each> </Data> </xsl:template> </xsl:stylesheet>

Snip of perl script for XSLT Conversion:

foreach my $file (@files) { eval('use XML::LibXML'); eval('use XML::LibXSLT'); my $oXslt = XML::LibXSLT->new(); my $oSource = XML::LibXML->load_xml(location => $file); my $oStylesheetDoc = XML::LibXML->load_xml(location => $cPath, no_cdat +a=>1); my $hXSLTDoc = $oXslt->parse_stylesheet($oStylesheetDoc); my $hOutput = $hXSLTDoc->transform($oSource); my $cFilecontent = $hXSLTDoc->output_as_bytes($hOutput); my $cConvertedFile = $file."_Converted.XML"; open(FH,">$cConvertedFile") or die "cannot open $cConvertedFile : $!\n +"; print FH $cFilecontent; close(FH); }


In reply to Please help with the issue in XML::LibXSLT module by denzil_cactus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.