Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2009, 12:40 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Hmm, removing an XML declaration in the XML input fixes the stylesheet result? That sounds rather odd.
As for the check I think you want to change the template for '' elements to the following:
Code:
  <xsl:template match="REF">
    <xsl:copy>
      <xsl:apply-templates select="@* | L_TO_C"/>
      <xsl:if test="not(doc2c)">
        <xsl:apply-templates select="/Tremble/Dakota/doc" mode="m1"/>
      </xsl:if>
      <xsl:apply-templates select="r2p"/>
    </xsl:copy>
  </xsl:template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old September 17th, 2009, 01:09 PM
Authorized User
 
Join Date: Sep 2009
Posts: 14
Thanks: 6
Thanked 0 Times in 0 Posts
Default Elements in doc2c

The stylesheet needs another tweak. It looks like elements in the original EMB container are getting output into doc2c. How can I fix this?

Result xml is below:

Code:
<Tremble>
	<Dakota>
		<L>
			<Li>123456</Li>
		</L>
		<C>
			<CID>69538</CID>
		</C>
		<PAR/>
		<PAR/>
		<doc>
			<EMB>
				<pinfo>
					<pid>2</pid>
					<pd>desc</pd>
				</pinfo>
				<enc>
					<pic>gberish2</pic>
				</enc>
			</EMB>
			<docid>1</docid>
			<dt>pho</dt>
		</doc>
		<doc>
			<EMB>
				<pinfo>
					<pid>4</pid>
					<pd>desc</pd>
				</pinfo>
				<enc>
					<pic>gberish4</pic>
				</enc>
			</EMB>
			<docid>2</docid>
			<dt>pho</dt>
		</doc>
		<doc>
			<EMB>
				<pinfo>
					<pid>6</pid>
					<pd>desc</pd>
				</pinfo>
				<enc>
					<pic>gberish6</pic>
				</enc>
			</EMB>
			<docid>3</docid>
			<dt>pho</dt>
		</doc>
		<REF>
			<L_TO_C>
				<L>123</L>
				<CID>69538</CID>
			</L_TO_C>
			<doc2c>2descgberish2<docid>1</docid>pho<CID>69538</CID></doc2c>
			<doc2c>4descgberish4<docid>67</docid>pho<CID>69538</CID></doc2c>
			<doc2c>6descgberish6<docid>45</docid>pho<CID>69538</CID></doc2c>
			<r2p>part1</r2p>
			<r2p>part1</r2p>
		</REF>
		<DID/>
	</Dakota>
	<ver>22</ver>
</Tremble>
 
Old September 18th, 2009, 06:25 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Here is an adapted stylesheet:
Code:
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>
  
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="doc/docid">
    <xsl:copy>
      <xsl:number count="doc"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="REF">
    <xsl:copy>
      <xsl:apply-templates select="@* | L_TO_C"/>
      <xsl:if test="not(doc2c)">
        <xsl:apply-templates select="/Tremble/Dakota/doc" mode="m1"/>
      </xsl:if>
      <xsl:apply-templates select="r2p"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="doc" mode="m1">
    <doc2c>
      <xsl:apply-templates select="docid" mode="m1"/>
      <xsl:apply-templates select="/Tremble/Dakota/C/CID"/>
    </doc2c>
  </xsl:template>
  
  <xsl:template match="doc/docid" mode="m1">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
fixit (September 23rd, 2009)
 
Old September 24th, 2009, 04:52 PM
Authorized User
 
Join Date: Sep 2009
Posts: 14
Thanks: 6
Thanked 0 Times in 0 Posts
Default Variations between processors

I successfully implemented this solution with XMLSpy and tested the transformation with the built in XLST processor and the MSXML processor you can switch to. However, I am told by an associate that the transform does not work correctly when using the XslCompiledTransform class and the Transform method, using VB.NET running in SQL Server Integration Services. That is, the new elements are not inserted.

Could there be a nuance that makes this not work in that system? I understand that that class is based on XSLT 1.0? Is there something related to 2.0 that is in this code? Thanks for your assistance again.
 
Old September 25th, 2009, 05:36 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Both MSXML and XslCompiledTransform are XSLT 1.0 processors. Furthermore the stylesheet in Insert multiple elements based on values of others is an XSLT 1.0 stylesheet.

We can try to look into why it fails with XslCompiledTransform: to do that please post minimal but complete input and stylesheet samples that fail.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple values insert into one field mateenmohd Classic ASP Basics 0 May 29th, 2007 02:11 AM
insert multiple records into a table from values Deepak Chauhan Oracle 3 May 12th, 2006 10:35 PM
insert multiple checkbox values in to database [email protected] Pro JSP 0 March 29th, 2006 08:23 AM
How t o insert multiple values qazi_nomi Access ASP 2 May 3rd, 2005 12:45 AM
convert elements based on place in document jefke XSLT 2 May 17th, 2004 05:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.