Hello experts,
I am new to XSL and would like to transform a NewML G2 format XML into another XML.
For example I have:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
SUMMARY:
- Structure: NML2 SNI Text
- Based On: NAR v1.2_1, NML2 v2.1_1
AUTHOR:
--><!-- ========================================================= -->
<newsMessage xmlns="http://iptc.org/std/nar/2006-10-01/" xmlns:rtr="http://www.reuters.com/ns/2003/08/content" xmlns:x="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<transmitId>tag:123.com,0000:newsml_N19279043:609406403</transmitId>
<priority>3</priority>
<destination>ABX</destination>
</header>
<itemSet>
<newsItem conformance="power" guid="tag:reuters.com,0000:newsml_N19279043" standard="NewsML-G2" standardversion="2.1" version="609406403" xml:lang="en">
<itemMeta>
<itemClass qcode="icls:text" rtr:msgType="S"/>
<provider literal="reuters.com"/>
<versionCreated>2011-05-20T05:00:27.000Z</versionCreated>
</itemMeta>
<contentMeta>
<urgency>3</urgency>
<infoSource literal="Reuters" role="cRole:origProv"/>
<subject qcode="N2:BNK"/>
<subject qcode="N2:BANK"/>
<subject qcode="R:BANK"/>
<slugline separator="-">FINANCIAL-REGULATION/OTC (ANALYSIS, REPEAT)</slugline>
<headline>My Headline</headline>
<by>ABC</by>
</contentMeta>
<contentSet>
<inlineXML contenttype="application/xhtml+html" wordcount="881">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body>
<p>Paragraph A</p>
<p>* Paragraph A</p>
</body>
</html>
</inlineXML>
</contentSet>
</newsItem>
</itemSet>
</newsMessage>
I would like my result XML to be something like:
<?xml version="1.0" encoding="UTF-8"?>
<MyData>
<MyTransmitId>tag:123.com,0000:newsml_N19279043:609406403</MyTransmitId>
<MyHeadline>My Headline</MyHeadline>
<MyContent>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title/>
</head>
<body>
<p>Paragraph A</p>
<p>* Paragraph A</p>
</body>
</html>
</MyContent>
</MyData>
I come out with the following XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt">
<xsl:output method="xml" indent="yes" encoding="utf-8" />
<xsl:template match="/newsMessage">
<MyTransmitId>
<xsl:value-of select="header/transmitId"/>
</MyTransmitId>
<MyHeadline>
<xsl:value-of select="itemSet/newsItem/contentMeta/headline"/>
</MyHeadline>
<MyContent>
<xsl:value-of select="itemSet/newsItem/contentSet/inlineXML"/>
</MyContent>
</xsl:template>
</xsl:stylesheet>
However it transforms to something not quite right.
What is wrong with my XSL?
Thank you very much.
Best regards,
Citydusk