Solved

Microsoft Friendly XSLT

Posted on 2007-03-29
2
323 Views
Last Modified: 2013-11-18
I'm trying to mirror a java program in C Sharp - part of the program is an XSL transformation of an existing XML document. The code I've been given for the java version is

<?xml version="1.0"?>
<dsig:Transforms xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:gt="http://www.govtalk.gov.uk/CM/envelope" xmlns:ir="http://www.govtalk.gov.uk/taxation/CISrequest">
<dsig:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
<dsig:XPath>
count(ancestor-or-self::node()|/gt:GovTalkMessage/gt:Body)=count(ancestor-or-self::node())
 and count(self::ir:IRmark)=0
 and count(../self::ir:IRmark)=0
</dsig:XPath>
</dsig:Transform>
<dsig:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
</dsig:Transforms>

However when i try and load that into my CSharp transformer object I get an XSLT compile error

The XML document its transforming is

<?xml version="1.0"?>
<GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
      <EnvelopeVersion>1.0</EnvelopeVersion>
      <Header>
            <MessageDetails>
                  <Class>IR-CIS-VERIFY</Class>
                  <Qualifier>request</Qualifier>
                  <Function>submit</Function>
                  <CorrelationID />
                  <ResponseEndPoint />
                  <Transformation>XML</Transformation>
                  <GatewayTest>1</GatewayTest>
                  <GatewayTimestamp />
            </MessageDetails>
            <SenderDetails>
                  <IDAuthentication>
                        <SenderID>CISRUSER1015</SenderID>
                        <Authentication>
                              <Method>clear</Method>
                              <Value>testing1</Value>
                        </Authentication>
                  </IDAuthentication>
            </SenderDetails>
      </Header>
      <GovTalkDetails>
            <Keys>
                  <Key Type="TaxOfficeNumber">123</Key>
                  <Key Type="TaxOfficeReference">R216</Key>
            </Keys>
            <TargetDetails>
                  <Organisation>IR</Organisation>
            </TargetDetails>
            <ChannelRouting>
                  <Channel>
                        <URI>0883</URI>
                  </Channel>
            </ChannelRouting>
      </GovTalkDetails>
      <Body>
            <IRenvelope xmlns="http://www.govtalk.gov.uk/taxation/CISrequest">
                  <IRheader>
                        <Keys>
                              <Key Type="TaxOfficeNumber">123</Key>
                              <Key Type="TaxOfficeReference">R216</Key>
                        </Keys>
                        <PeriodEnd>2007-03-31</PeriodEnd>
                        <DefaultCurrency>GBP</DefaultCurrency>
                        <IRmark Type="generic"></IRmark>
                        <Sender>Employer</Sender>
                  </IRheader>
                  <CISrequest>
                        <Contractor>
                              <UTR>4325648152</UTR>
                              <AOref>123PP87654321</AOref>
                        </Contractor>
                        <Subcontractor>
                              <Action>verify</Action>
                              <Type>partnership</Type>
                              <TradingName>Foundations</TradingName>
                              <WorksRef>WR3000</WorksRef>
                              <UTR>1234567890</UTR>
                              <CRN>AB123456</CRN>
                              <NINO>PR456789B</NINO>
                              <Partnership>
                                    <Name>Mark &amp; Sons</Name>
                                    <UTR>0123456789</UTR>
                              </Partnership>
                              <Address>
                                    <Line>21 High Street</Line>
                                    <Line>Wellington</Line>
                                    <Line>Telford</Line>
                                    <Line>Shropshire</Line>
                                    <PostCode>BD18</PostCode>
                                    <Country>UK</Country>
                              </Address>
                              <Telephone>01952123456</Telephone>
                        </Subcontractor>
                        <Declaration>yes</Declaration>
                  </CISrequest>
            </IRenvelope>
      </Body>
</GovTalkMessage>

the object of the XSLT transformation is to place the xmlns attribute of the GovTalkMessage in the body tag and extract the body tag then and its contents. Has anyone got any microsoft friendly XML to do this.
0
Comment
Question by:CMSIRL
2 Comments
 
LVL 12

Expert Comment

by:ShazbotOK
Comment Utility
the XSLT seems to have some embedded java/javascript in it - this could be part of the culprit of your problem.

If that is indeed the problem then you will want to check out the MSDN tutorial on using msxsl:script:
http://msdn2.microsoft.com/en-us/library/wxaw5z5e.aspx

if you are using the XslCompiledTransform method to load this you may need to note that the default REQUIRED namespace contained in the XSLT is http://www.w3.org/1999/XSL/Transform.
0
 
LVL 12

Accepted Solution

by:
jkmyoung earned 500 total points
Comment Utility
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gt="http://www.govtalk.gov.uk/CM/envelope" xmlns:ir="http://www.govtalk.gov.uk/taxation/CISre">
<xsl:template match="/*">
      <xsl:copy-of select="//gt:Body"/>
</xsl:template>
</xsl:stylesheet>

Please provide your expected output if this isn't correct.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now