Hello,
I have the following xml file
Code:
<?xml version="1.0" encoding="utf-8"?>
<be:byggesak identifier="string" xmlns:be="http://www.be.no/xml/ns/byggesak" xmlns:iso3166="http://www.unece.org/etrades/unedocs/repository/codelists/xml/CountryCode.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.be.no/xml/ns/byggesak file:///X:/Projects/BYGGS%C3%98K/11217%20ByggS%C3%B8k%20bygning%20v.3.0/WebServices/internal_xsd_byggesak/byggesak_0_3.xsd">
<be:soknadid>soknad_ehsan1</be:soknadid>
<be:saksid be:eier="string" />
<be:byggesaksprosess>
<be:soknadendringtillatelse>
<be:endringansvarsrett>true</be:endringansvarsrett>
<be:endringavansvarligsoker>true</be:endringavansvarligsoker>
<be:endringdispensasjon>true</be:endringdispensasjon>
<be:endringareal>true</be:endringareal>
<be:endringplassering>true</be:endringplassering>
<be:endringformal>true</be:endringformal>
<be:endringbruk>true</be:endringbruk>
<be:endringavtiltak>flase</be:endringavtiltak>
<be:endringannet> true</be:endringannet>
<be:beskrivelse>be:beskrivelse</be:beskrivelse>
</be:soknadendringtillatelse>
....
...
</be:byggesak>
I am trying to change the format of this using XSLT. so I have this code
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" exclude-result-prefixes="xs xdt err fn"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:iso3166="http://www.unece.org/etrades/unedocs/repository/codelists/xml/CountryCode.xsd"
xmlns:be="http://www.be.no/xml/ns/byggesak"
xsi:schemaLocation="http://www.be.no/xml/ns/byggesak file:///O:\byggsok\svn\XMLConverter\XSLT\Version0_3To2_0Transformation\Version0_3To2_0Transformation\Schemas\old\byggesak_0_3.xsd">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<!-- byggesak-->
<xsl:template match="be:byggesak">
<!--create the element with its attributes-->
<xsl:element name="be:byggesak">
<xsl:attribute name="soknadid">
<xsl:value-of select="be:soknadid"/>
<!-- get the value of the soknadid element and put it here -->
</xsl:attribute>
<xsl:attribute name="byggesaksid"/>
<xsl:attribute name="soknadstype"/>
<!-- create sak element and search for other elements -->
<xsl:element name="be:sak">
<!-- since soknadid and saksid aren't needed any more, it will just jump to byggesaksprocess -->
<xsl:apply-templates />
</xsl:element>
</xsl:element>
</xsl:template>
<!-- byggesaksprocess and its children-->
<xsl:template match="be:byggesaksprosess">
<xsl:element name="be:soknad">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!--START byggesaksprosess/soknadendringtillatelse-->
<xsl:template match="be:soknadendringtillatelse">
<xsl:element name="be:endringavtillatelse">
<xsl:apply-templates/>
<xsl:element name="kommunenssaksnummer"/>
<xsl:text>
</xsl:text><!--new line, just for the looks;-) -->
</xsl:element>
</xsl:template>
<xsl:template match="be:beskrivelse">
<xsl:element name="be:beskrivelse">
<xsl:value-of select="be:beskrivelse"/>
</xsl:element>
</xsl:template>
....
....
...
I have done this for all the nodes and their children. My problem is the <xsl:value-of > element doesn't give me any output, beside the value of the attribute I've created? I don't understand why this happens. As far as I have read it should print out the value of the select node as a string. so why isn't it working here?
This is the output:
Code:
<?xml version="1.0" encoding="utf-8"?>
<be:byggesak soknadid="soknad_ehsan1" byggesaksid="" soknadstype="" xmlns:be="http://www.be.no/xml/ns/byggesak">
<be:sak>
soknad_ehsan1
<be:soknad>
<be:endringavtillatelse>
<be:endringansvarsrett></be:endringansvarsrett>
<be:endringavansvarligsoker></be:endringavansvarligsoker>
<be:endringdispensasjon></be:endringdispensasjon>
<be:endringareal></be:endringareal>
<be:endringplassering></be:endringplassering>
<be:endringformal></be:endringformal>
<be:endringbruk></be:endringbruk>
<be:endringannet></be:endringannet>
<be:beskrivelse></be:beskrivelse>
<kommunenssaksnummer />
</be:endringavtillatelse>
<be:igangsettingstillatelse>
<be:delsoknad>
<be:kommentar />
<be:kommunenssaksnummer /></be:delsoknad>
<be:delsoknad>
<be:delavtiltaket />
....
....
....
I must admit that I am not a xslt programmer, work with C,C# and JAVA most of the time.
one other question
I am processing the soknadid node as an attribute which works, but I still its output, how can I skip certain nodes that I don't want to process.
cheers,
es