Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XML/XSL transformation questions

From: Ronald Pothuizen <rpothuiz@-------------.---.--->
To: NULL
Date: 6/7/2007 3:14:00 PM

Hi,

I am fairly new to XML/XSL, but I can do most I need (which is not
much ;-)). Now I need something a bit more complicated, or anyway, I
don't know how to do it (yet).

Directives:
1. go from XML 1 to XML 2 with use of XSL (figures)
2. copy only every NON-repetitive node (in this case everything but
BOAs) from <Opsporingsdocument> to <Docvars>
3. copy repetitive nodes <BOAs> to <repeaters>

(1) and (3) I can do, but (2) is difficult, I can copy the complete
node (as you can see) but I cannot get the XSL to copy only the
non-repetitive parts. Once I created a twin step (2 XSL
transformations after each other) the second one deleted a
transformed_and_copied node from the first result. In this case that
probably does not work, because it would delete also the same node in
<repeaters>. Anyway, I'd rather have a one step XSL.

Can anyone point me in the right direction? If you need more input,
just ask...

BTW: contents is test, so there may be typing errors.

Thanks,

Ronald

XML:
<?xml version="1.0" encoding="ISO-8859-15"?>
<Totaal>
  <Algemeen>
    <Documenttype>Some data that does not need
transformation</Documenttype>    
  </Algemeen>
  <Opsporingsdocumenten>
    <Opsporingsdocument>
      <osz_nummer>465</osz_nummer>
      <osd_nummer>564</osd_nummer>
      <Aantal_getuigen>1</Aantal_getuigen>
      <Aantal_BOAs>2</Aantal_BOAs>
      <BOAs>
        <BOA>
          <bmw_naam_voluit><![CDATA[Willem]]></bmw_naam_voluit>
          <bmw_akte><![CDATA[123456/2]]></bmw_akte>
          <bmw_eedbelofte><![CDATA[ambtsbelofte]]></bmw_eedbelofte>
          <bmw_namen_voluit><![CDATA[Willem en
Maarten]]></bmw_namen_voluit>
          <bmw_aktes><![CDATA[123456/2 en 123456/0]]></bmw_aktes>
          <bmw_eden><![CDATA[ambtsbelofte en
ambtsbelofte]]></bmw_eden>
        </BOA>
        <BOA>
          <bmw_naam_voluit><![CDATA[Maarten]]></bmw_naam_voluit>
          <bmw_akte><![CDATA[123456/0]]></bmw_akte>
          <bmw_eedbelofte><![CDATA[ambtsbelofte]]></bmw_eedbelofte>
          <bmw_namen_voluit><![CDATA[Willem en
Maarten]]></bmw_namen_voluit>
          <bmw_aktes><![CDATA[123456/2 en 123456/0]]></bmw_aktes>
          <bmw_eden><![CDATA[ambtsbelofte en
ambtsbelofte]]></bmw_eden>
        </BOA>
      </BOAs>
    </Opsporingsdocument>
  </Opsporingsdocumenten>
</Totaal>

Current XSL: (not good)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"
xmlns:xalan="http://xml.apache.org/xslt" xalan:indent-amount="4"
encoding="UTF-8" />

<xsl:template match="Totaal">
<noffice>
	<xsl:apply-templates
select="Opsporingsdocumenten/Opsporingsdocument" />
	<repeaters>
		<BOAs>
			<xsl:apply-templates
select="Opsporingsdocumenten/Opsporingsdocument/BOAs" />
		</BOAs>
	</repeaters>
</noffice>
</xsl:template>

<xsl:template match="Opsporingsdocumenten/Opsporingsdocument">
<docvars>
	<xsl:copy-of select="node()"/>
</docvars>
</xsl:template>

<xsl:template match="Opsporingsdocumenten/Opsporingsdocument/BOAs">
	<xsl:copy-of select="node()"/>
</xsl:template>

</xsl:stylesheet>

Current Result XML:
<?xml version="1.0" encoding="UTF-16" ?> 
<noffice>
	<docvars>
	  <osz_nummer>465</osz_nummer> 
	  <osd_nummer>564</osd_nummer> 
	  <Aantal_getuigen>1</Aantal_getuigen> 
	  <Aantal_BOAs>2</Aantal_BOAs> 
		<BOAs>
			<BOA>
			  <bmw_naam_voluit>Willem</bmw_naam_voluit> 
			  <bmw_akte>123456/2</bmw_akte> 

<bmw_eedbelofte>ambtsbelofte</bmw_eedbelofte> 
			  <bmw_namen_voluit>Willem en
Maarten</bmw_namen_voluit> 
			  <bmw_aktes>123456/2 en 123456/0</bmw_aktes> 
			  <bmw_eden>ambtsbelofte en
ambtsbelofte</bmw_eden> 
			</BOA>
			<BOA>
			  <bmw_naam_voluit>Maarten</bmw_naam_voluit> 
			  <bmw_akte>123456/0</bmw_akte> 

<bmw_eedbelofte>ambtsbelofte</bmw_eedbelofte> 
			  <bmw_namen_voluit>Willem en
Maarten</bmw_namen_voluit> 
			  <bmw_aktes>123456/2 en 123456/0</bmw_aktes> 
			  <bmw_eden>ambtsbelofte en
ambtsbelofte</bmw_eden> 
      </BOA>
    </BOAs>
  </docvars>
	<repeaters>
		<BOAs>
			<BOA>
			  <bmw_naam_voluit>Willem</bmw_naam_voluit> 
			  <bmw_akte>123456/2</bmw_akte> 

<bmw_eedbelofte>ambtsbelofte</bmw_eedbelofte> 
			  <bmw_namen_voluit>Willem en
Maarten</bmw_namen_voluit> 
			  <bmw_aktes>123456/2 en 123456/0</bmw_aktes> 
			  <bmw_eden>ambtsbelofte en
ambtsbelofte</bmw_eden> 
			</BOA>
			<BOA>
			  <bmw_naam_voluit>Maarten</bmw_naam_voluit> 
			  <bmw_akte>123456/0</bmw_akte> 

<bmw_eedbelofte>ambtsbelofte</bmw_eedbelofte> 
			  <bmw_namen_voluit>Willem en
Maarten</bmw_namen_voluit> 
			  <bmw_aktes>123456/2 en 123456/0</bmw_aktes> 
			  <bmw_eden>ambtsbelofte en
ambtsbelofte</bmw_eden> 
      </BOA>
    </BOAs>
  </repeaters>
</noffice>
-- 
-----------------------------------------------
User error: Please replace user and try again.
http://blog.pothuizen.net


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent