Advertisement

10.04.2005 at 01:23AM PDT, ID: 21582902
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

xsl transformation - issue to transform element and attributes when mulitple instances

Asked by alain34 in Extensible Markup Language (XML), Extensible HTML (XHTML)

Tags: , ,

I have a xml document like this one

<?xml version="1.0" encoding="UTF-8"?>
<Message>
      <Header>
            <BrokerID>MAR01</BrokerID>
            <TMStamp>2005-10-04T08:50:43</TMStamp>
      </Header>
      <ReportDetails>
            <ReportCode>01</ReportCode>
            <ReportFromDate>          </ReportFromDate>
            <ReportToDate>          </ReportToDate>
      </ReportDetails>
      <ReportData>
            <Definition>
                  <Column ID="1" Name="Client Name" DataType="CHAR" Total="N"/>
                  <Column ID="2" Name="Client Reference" DataType="CHAR" Total="N"/>
                  <Column ID="3" Name="Policy Number" DataType="CHAR" Total="N"/>
                  <Column ID="4" Name="Insurer" DataType="CHAR" Total="N"/>
                  <Column ID="5" Name="Net Premium" DataType="NUMBER" Total="N"/>
                  <Column ID="6" Name="Brokerage" DataType="NUMBER" Total="N"/>
                  <Column ID="7" Name="Inception Date" DataType="DATE" Total="N"/>
            </Definition>
            <Data>
                  <Row>
                        <Cell ID="1" Value="Value1"/>
                        <Cell ID="2" Value="Value2"/>
                        <Cell ID="3" Value="Value3"/>
                        <Cell ID="4" Value="Value4"/>
                        <Cell ID="5" Value="Value5"/>
                        <Cell ID="6" Value="Value6"/>
                        <Cell ID="7" Value="Value7"/>
                  </Row>
            </Data>
            <Row>
                  <Cell ID="1" Value="Value11"/>
                  <Cell ID="2" Value="Value12"/>
                  <Cell ID="3" Value="Value13"/>
                  <Cell ID="4" Value="Value14"/>
                  <Cell ID="5" Value="Value15"/>
                  <Cell ID="6" Value="Value16"/>
                  <Cell ID="7" Value="Value17"/>
            </Row>
      </ReportData>
      <ReportSummary>
            <NoColumns>  0</NoColumns>
            <NoRows>  0</NoRows>
      </ReportSummary>
      <Status>
            <Reason>Request successful</Reason>
            <Code>1</Code>
      </Status>
</Message>

I'm applying the following stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
            <Message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ActurisReportReply.xsd">
                  <xsl:apply-templates select="Message"/>
            </Message>
      </xsl:template>
      <xsl:template match="Message">
            <xsl:apply-templates select="Header"/>
            <xsl:apply-templates select="ReportDetails"/>
            <xsl:apply-templates select="ReportSummary"/>
            <xsl:apply-templates select="ReportData"/>
            <xsl:apply-templates select="Status"/>
      </xsl:template>
      <xsl:template match="Header">
            <xsl:element name="{name()}">
                  <xsl:attribute name="Transaction"><xsl:text>AcceptReportReply</xsl:text></xsl:attribute>
                  <xsl:attribute name="BrokerID"><xsl:value-of select="BrokerID"/></xsl:attribute>
                  <xsl:attribute name="TMStamp"><xsl:value-of select="TMStamp"/></xsl:attribute>
            </xsl:element>
      </xsl:template>
      <xsl:template match="ReportDetails">
            <xsl:element name="{name()}">
                  <xsl:attribute name="ReportCode"><xsl:value-of select="ReportCode"/></xsl:attribute>
                  <xsl:attribute name="ReportFromDate"><xsl:value-of select="ReportFromDate"/></xsl:attribute>
                  <xsl:attribute name="ReportToDate"><xsl:value-of select="ReportToDate"/></xsl:attribute>
            </xsl:element>
      </xsl:template>
      <xsl:template match="ReportSummary">
            <xsl:element name="{name()}">
                  <xsl:attribute name="NoColumns"><xsl:value-of select="NoColumns"/></xsl:attribute>
                  <xsl:attribute name="NoRows"><xsl:value-of select="NoRows"/></xsl:attribute>
            </xsl:element>
      </xsl:template>
      <xsl:template match="ReportData">
            <xsl:element name="{name()}">
                  <xsl:apply-templates select="Definition"/>
                  <xsl:apply-templates select="Data"/>
            </xsl:element>
      </xsl:template>
      <xsl:template match="Status">
            <xsl:element name="{name()}">
                  <xsl:attribute name="Reason"><xsl:value-of select="Reason"/></xsl:attribute>
                  <xsl:attribute name="Code"><xsl:value-of select="Code"/></xsl:attribute>
            </xsl:element>
      </xsl:template>
      <xsl:template match="Definition">
            <xsl:element name="{name()}">
                  <xsl:for-each select="Column">
                        <xsl:apply-templates select="Column"/>
                  </xsl:for-each>
            </xsl:element>
      </xsl:template>
      <xsl:template match="Data">
            <xsl:element name="{name()}">
            </xsl:element>
      </xsl:template>
      <xsl:template match="Column">
            <xsl:element name="{name()}">
            </xsl:element>
      </xsl:template>      
</xsl:stylesheet>

I would like the following result :

<?xml version="1.0" encoding="UTF-16"?>
<Message xsi:noNamespaceSchemaLocation="ActurisReportReply.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Header Transaction="AcceptReportReply" BrokerID="MAR01" TMStamp="2005-10-04T08:50:43" />
      <ReportDetails ReportCode="01" ReportFromDate=" " ReportToDate=" " />
      <ReportSummary NoColumns="  0" NoRows="  0" />
      <ReportData>
            <Definition>
                  <Column ID="1" Name="Client Name" DataType="CHAR" Total="N" />
                  <Column ID="2" Name="Client Reference" DataType="CHAR" Total="N" />
                  <Column ID="3" Name="Policy Number" DataType="CHAR" Total="N" />
                  <Column ID="4" Name="Insurer" DataType="CHAR" Total="N" />
                  <Column ID="5" Name="Net Premium" DataType="NUMBER" Total="N" />
                  <Column ID="6" Name="Brokerage" DataType="NUMBER" Total="N" />
                  <Column ID="7" Name="Inception Date" DataType="DATE" Total="N" />
            </Definition>
            <Data>
                  <Row>
                        <Cell ID="1" Value="Value1" />
                        <Cell ID="2" Value="Value2" />
                        <Cell ID="3" Value="Value3" />
                        <Cell ID="4" Value="Value4" />
                        <Cell ID="5" Value="Value5" />
                        <Cell ID="6" Value="Value6" />
                        <Cell ID="7" Value="Value7" />
                  </Row>
                  <Row>
                        <Cell ID="1" Value="Value11" />
                        <Cell ID="2" Value="Value12" />
                        <Cell ID="3" Value="Value13" />
                        <Cell ID="4" Value="Value14" />
                        <Cell ID="5" Value="Value15" />
                        <Cell ID="6" Value="Value16" />
                        <Cell ID="7" Value="Value17" />
                  </Row>
            </Data>
      </ReportData>
      <Status Reason="Request successful" Code="1" />
</Message>

But instead I get the following :

<?xml version="1.0" encoding="UTF-16"?>
<Message xsi:noNamespaceSchemaLocation="ActurisReportReply.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Header Transaction="AcceptReportReply" BrokerID="MAR01" TMStamp="2005-10-04T08:50:43" />
      <ReportDetails ReportCode="01" ReportFromDate=" " ReportToDate=" " />
      <ReportSummary NoColumns="  0" NoRows="  0" />
      <ReportData>
            <Definition />
            <Data />
      </ReportData>
      <Status Reason="Request successful" Code="1" />
</Message>

Can somebody help me to get the result I need!!!

Start Free Trial
[+][-]10.04.2005 at 02:28AM PDT, ID: 15012427

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), Extensible HTML (XHTML)
Tags: xsl, reportdata, row
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 3
Solution Grade: B
 
 
[+][-]10.04.2005 at 02:29AM PDT, ID: 15012435

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.04.2005 at 02:29AM PDT, ID: 15012437

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.04.2005 at 02:40AM PDT, ID: 15012487

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.05.2005 at 12:00AM PDT, ID: 15019787

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32