XSLT 1.0 String split template not working - xslt-1.0

I am new to XSLT and am having an issue with templates. I have an input xml file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Node>
<PHASE1_TYPE>LEFT,TOP</PHASE1_TYPE>
<PHASE1_HOL>TOK,ZUR,VIN</PHASE1_HOL>
<PHASE2_TYPE>RIGHT,BOTTOM</PHASE2_TYPE>
<PHASE2_HOL>CHF</PHASE2_HOL>
</Node>
My xslt is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template name="tokenize">
<xsl:param name="text" select="."/>
<xsl:param name="separator" select="','"/>
<xsl:choose>
<xsl:when test="not(contains($text, $separator))">
<Holiday>
<xsl:value-of select="normalize-space($text)"/>
</Holiday>
</xsl:when>
<xsl:otherwise>
<Holiday>
<xsl:value-of select="normalize-space(
substring-before($text, $separator))"/>
</Holiday>
<xsl:call-template name="tokenize">
<xsl:with-param name="text"
select="substring-after($text, $separator)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<Document>
<xsl:attribute name="xsi:noNamespaceSchemaLocation"
namespace="http://www.w3.org/2001/XMLSchema-instance"
>C:/usr/NONMAR~1/Output.xsd</xsl:attribute>
<xsl:for-each select="Node">
<Deal>
<DealType>
<xsl:value-of select="string(PHASE1_TYPE)"/>
</DealType>
<Holidays>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="string(PHASE1_HOL)"/>
<xsl:with-param name="separator" select="','"/>
</xsl:call-template>
</Holidays>
</Deal>
<Deal>
<DealType>
<xsl:value-of select="string(PHASE2_TYPE)"/>
</DealType>
<Holidays>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="string(PHASE2_HOL)"/>
<xsl:with-param name="separator" select="','"/>
</xsl:call-template>
</Holidays>
</Deal>
</xsl:for-each>
</Document>
</xsl:template>
</xsl:stylesheet>
After transformation, my output is:
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:/usr/NONMAR~1/Output.xsd">
<Deal>
<DealType>LEFT,TOP</DealType>
<Holidays>
<Holiday/>
</Holidays>
</Deal>
<Deal>
<DealType>RIGHT,BOTTOM</DealType>
<Holidays>
<Holiday/>
</Holidays>
</Deal>
</Document>
but the expected Output is :
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:/usr/NONMAR~1/Output.xsd">
<Deal>
<DealType>LEFT,TOP</DealType>
<Holidays>
<Holiday>TOK</Holiday>
<Holiday>ZUR</Holiday>
<Holiday>VIN</Holiday>
</Holidays>
</Deal>
<Deal>
<DealType>RIGHT,BOTTOM</DealType>
<Holidays>
<Holiday>CHF</Holiday>
</Holidays>
</Deal>
</Document>
I am using xslt 1.0 and do not want to use third party functions like EXSLT. Again, I am new to XSLT and do not have time right now to learn it. Would really appreciate if someone can tell me why this template is not working properly. Thanks!!

Sorry, but it's impossible to tell, from the information you provide.
On the plus side, you've taken some effort to cut your stylesheet and your sample input down in size and simplify them. That's good; I wish more new Stack Overflow users knew to do that.
On the minus side, the code you provide doesn't produce the output you show from the input you show. First of all, it's not well-formed; the end-tag for an xsl:for-each has gotten left out. And then that for-each, in the template for the document node, uses select="Node", which looks for elements named Node which are children of the document node -- but in your input, the only element child of the document node is named 'Root'. And your tokenization template wraps the individual tokens in item elements, instead of Holiday elements. When the first two slips are fixed, the stylesheet appears to produce the output you desire (modulo the Holiday/item issue):
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"C:/usr/NONMAR~1/Output.xsd">
<Deal>
<DealType>LEFT,TOP</DealType>
<Holidays>
<item>TOK</item>
<item>ZUR</item>
<item>VIN</item>
</Holidays>
</Deal>
<Deal>
<DealType>RIGHT,BOTTOM</DealType>
<Holidays>
<item>CHF</item>
</Holidays>
</Deal>
</Document>

Related

XPTY0004: An empty sequence is not allowed as the value of variable while loading xslt using saxon templatefactory

I updated the provided xslt to accept a param "multiplexpaths" from my source and assignin enter code here`g this to nodes variable in xslt to below:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:param name="multiplexpaths" as="xs:string" static="yes" />
<!-- xsl:param name="copy" as="xs:string" static="yes" select="'//other[. = 1345], //more[. = 2]'"/-->
<xsl:variable name="nodes" _select="{$multiplexpaths}"/>
<xsl:variable name="ancestors" select="$nodes/ancestor::*"/>
<xsl:mode on-no-match="shallow-skip"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="$nodes">
<xsl:sequence select="."/>
</xsl:template>
<xsl:template match="$ancestors">
<xsl:copy>
<xsl:copy-of select="#*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
For the xsl:evaluate example, you would need to use Saxon 10 HE, 9.9 HE doesn't support xsl:evaluate.
As for setting a static parameter with Saxon 9.9 and s9api, a simple example is
String paths = "catalog/cd1,catalog/Test/value/a1";
Processor processor = new Processor(true);
XsltCompiler xsltCompiler = processor.newXsltCompiler();
xsltCompiler.setParameter(new QName("copy"), new XdmAtomicValue(paths));
XsltExecutable xsltExecutable = xsltCompiler.compile(new StreamSource("static-param-example2.xsl"));
Xslt30Transformer xslt30Transformer = xsltExecutable.load30();
xslt30Transformer.transform(new StreamSource("input-sample1.xml"), xslt30Transformer.newSerializer(System.out));
with the input-sample1.xml being
<catalog>
<cd1>
<name>abc</name>
<Stext>1234</Stext>
<Tag>uuuu</Tag>
</cd1>
<cd2>
<name>abc</name>
<Stext>1234</Stext>
<Tag>uuuu</Tag>
</cd2>
<Test>
<value>
<a1>123</a1>
<b1>77474</b1>
</value>
</Test>
</catalog>
and the XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:param name="copy" as="xs:string" static="yes" select="'()'"/>
<xsl:variable name="nodes" _select="{$copy}"/>
<xsl:variable name="ancestors" select="$nodes/ancestor::*"/>
<xsl:mode on-no-match="shallow-skip"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="$nodes">
<xsl:sequence select="."/>
</xsl:template>
<xsl:template match="$ancestors">
<xsl:copy>
<xsl:copy-of select="#*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
this outputs
<catalog>
<cd1>
<name>abc</name>
<Stext>1234</Stext>
<Tag>uuuu</Tag>
</cd1>
<Test>
<value>
<a1>123</a1>
</value>
</Test>
</catalog>
So the main point is to set the parameter on the XsltCompiler and not after compilation on the transformer.

xslt nested transformation : unable to transnform

I am learning XSLT and trying to transform below xml. But couldn't achieve the task
<sample id="7">
<land1 id="8">
<owner>TOMMY</owner>
<type>INDIVIDUAL</type>
<hint>TOM_INDIVIDUAL</hint>
<date>12.02.2014</date>
<text>land details</text>
<number>1</number>
<cost>WIDERRUFLICH</cost>
</land1>
</sample>
and trying to convert above into
<table name="sample">
<tablename="land1">
<rel name="owner" value="TOMMY"/>
<rel name="type" value="INDIVIDUAL"/>
<rel name="<hint" value="TOM_INDIVIDUAL"/>
<rel name="date" value="12.02.2014"/>
<rel name="details" value="land details"/>
<rel name="number" value="1"/>
<rel name="cost" value="25%"/>
</table>
</table>
I tried below to generate the same, but it's not working.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="*">
<xsl:if test="current().count(*)>0">
<xsl:element name="table">
<xsl:attribute name="name">
<xsl:value-of select="name(.)"/>
</xsl:attribute>
<xsl:apply-templates select="/"
</xsl:element>
</xsl:if>
<xsl:if test="current().count(*)=0">
<xsl:element name="rel">
<xsl:attribute name="name">
<xsl:value-of select="name(.)"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="current()"/>
</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Can someone please let me know where I am doing wrong?
Can someone please let me know where I am doing wrong?
Well, for one thing, current().count(*)>0 is not a valid expression.
And you have <xsl:apply-templates select="/" without closing the tag. Which may be a good thing - because if it worked, it would have created an infinite loop.
I also don't understand the overall logic of your approach. Couldn't you do simply:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*[*]">
<table name="{name()}">
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="*">
<rel name="{name()}" value="{.}"/>
</xsl:template>
</xsl:stylesheet>
Added:
every element with an attribute should also be a table. For example,
in the above xml, <land1 id="8"> has children and your logic works
fine. But my inout can also contain <land1 id="8"/>. Now even though
it doesn't have any child elements, still element name has to be
considered as Table
Then use:
<xsl:template match="*[#*]">
instead of:
<xsl:template match="*[*]">

How to Parse Query parameters in XSLT

I have a requirement I will get the URL in the format like this below
https://sample.com?first=one&second=two&third=three
How can I form an xml structure below which will be formed by making use of this query parameters
<first>one</first><second>two</second><third>three</third>
can Please somebody help me with thisand provide me an xslt for this requirement
Given the following XML input (note the escaping of the ampersand character):
<URL>https://sample.com?first=one&second=two&third=three</URL>
the folowing stylesheet:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<output>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after(URL, '?')"/>
</xsl:call-template>
</output>
</xsl:template>
<xsl:template name="tokenize">
<xsl:param name="text"/>
<xsl:param name="delimiter" select="'&'"/>
<xsl:variable name="token" select="substring-before(concat($text, $delimiter), $delimiter)" />
<xsl:if test="$token">
<xsl:element name="{substring-before($token, '=')}">
<xsl:value-of select="substring-after($token, '=')"/>
</xsl:element>
</xsl:if>
<xsl:if test="contains($text, $delimiter)">
<!-- recursive call -->
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after($text, $delimiter)"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
will return:
<?xml version="1.0" encoding="UTF-8"?>
<output>
<first>one</first>
<second>two</second>
<third>three</third>
</output>
Note that this will work only if the query field names are also valid XML element names.

Custom XSLT Tag

I am sick of write all the call-template/with-param stuff.
Is there any shortcut for this in example:
<xsl:call-template name="complexwidget">
<xsl:with-param name="a" select="$bla_213"/>
<xsl:with-param name="b" select="$bla_213"/>
<xsl:with-param name="c" select="$bla_213"/>
<xsl:with-param name="d" select="$bla_213"/>
</xsl:call-template>
A Perfect posibility would be this:
<complex a="{$bla_213}" b="{$bla_213}" c="{$bla_213}" d="{$bla_213}" />
Any idea, maybe a twice-transform-xslt??
If you could switch to xslt 2.0 then user functions would be exactly what you need.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 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:my="my-namespace">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="my:complexWidget(1, 2, 3, 4)" />
</xsl:template>
<xsl:function name="my:complexWidget">
<xsl:param name="a" />
<xsl:param name="b" />
<xsl:param name="c" />
<xsl:param name="d" />
<!-- Do something -->
<xsl:value-of select="($a, $b,$c, $d)" separator="-" />
</xsl:function>
</xsl:stylesheet>
In xslt 1.0 I think that preprocessing of xslt stylesheet with another transformation will be the only way (or may be writing some extension functions in language of your processor .
EDIT:
I tried the "preprocess" of xslt and it seems to be working (but probably it is no the most elegant way how to do it).
Input xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mypp="my-preprocess-namespace">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:variable name="varA" select="1"/>
<xsl:variable name="varB" select="2"/>
<xsl:variable name="varC" select="3"/>
<xsl:variable name="varD" select="4"/>
<mypp:complexWidget a="$varA" b="$varB" c="$varC" d="$varD"/>
</xsl:template>
<xsl:template name="complexWidget">
<xsl:param name="a"/>
<xsl:param name="b"/>
<xsl:param name="c"/>
<xsl:param name="d"/>
<!-- do something-->
<xsl:value-of select="$a"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$b"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$c"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$d"/>
</xsl:template>
</xsl:stylesheet>
I defined here a special namespace for element to be replaced (i.e. xmlns:mypp="my-preprocess-namespace"). Element to be replaced is <mypp:complexWidget a="$varA" b="$varB" c="$varC" d="$varD"/>.
This xslt I preprocess with following xslt.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mypp="my-preprocess-namespace">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="node() | #*">
<xsl:copy>
<xsl:apply-templates select="node() | #*" />
</xsl:copy>
</xsl:template>
<xsl:template match="mypp:*">
<xsl:element name="xsl:call-template">
<xsl:attribute name="name">
<xsl:value-of select="local-name()" />
</xsl:attribute>
<xsl:for-each select="#*">
<xsl:element name="xsl:with-param">
<xsl:attribute name="name">
<xsl:value-of select="name()" />
</xsl:attribute>
<xsl:attribute name="select">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
It is based on "Identity transform" - copy everything to the output just elements from special namespace transform into the call-template element. I guess this could be done in more nice way than I did.
The output is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:mypp="my-preprocess-namespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:variable name="varA" select="1"/>
<xsl:variable name="varB" select="2"/>
<xsl:variable name="varC" select="3"/>
<xsl:variable name="varD" select="4"/>
<xsl:call-template name="complexWidget">
<xsl:with-param name="a" select="$varA"/>
<xsl:with-param name="b" select="$varB"/>
<xsl:with-param name="c" select="$varC"/>
<xsl:with-param name="d" select="$varD"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="complexWidget">
<xsl:param name="a"/>
<xsl:param name="b"/>
<xsl:param name="c"/>
<xsl:param name="d"/>
<!-- do something-->
<xsl:value-of select="$a"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$b"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$c"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$d"/>
</xsl:template>
</xsl:stylesheet>
When I run the output as xslt stylesheet it produces expected output.
But I don't have any deeper experience with producing xslt stylesheet by another xslt so I don't know much about possible troubles with this approach.

XSL 1.0 - Hiding Child nodes when child element is Null

I have been trying to make child elements of my structure hide based upon them being empty.
From reading other posts I found this Remove parent node if a child node is empty but I don't understand it enough to implement it in my XSL. I have had a try at applying the linked post to my XSL but it does not make the desired changes to my output.
So my XML is like this:
<?xml version="1.0" encoding="UTF-8" ?>
<exchange>
<sce>
<sce.srs>
<sce_scjc.sce.srs>140008305/1</sce_scjc.sce.srs>
<sce_seq2.sce.srs>01</sce_seq2.sce.srs>
<sce_stuc.sce.srs>140008305</sce_stuc.sce.srs>
<spr>
<spr.cams>
<spr_code.spr.cams>140008305/1</spr_code.spr.cams>
<prs_code.spr.cams>77711925</prs_code.spr.cams>
<prs>
<prs.mensys>
<prs_code.prs.mensys>77711925</prs_code.prs.mensys>
<prs_name.prs.mensys>Johan</prs_name.prs.mensys>
</prs.mensys>
</prs>
</spr.cams>
</spr>
</sce.srs>
<sce.srs>
<sce_scjc.sce.srs>151516736/1</sce_scjc.sce.srs>
<sce_seq2.sce.srs>01</sce_seq2.sce.srs>
<sce_stuc.sce.srs>151516736</sce_stuc.sce.srs>
<spr>
<spr.cams>
<spr_code.spr.cams>151516736/1</spr_code.spr.cams>
<prs_code.spr.cams>77709062</prs_code.spr.cams>
<prs>
<prs.mensys>
<prs_code.prs.mensys>77709062</prs_code.prs.mensys>
<prs_name.prs.mensys>Evangelia</prs_name.prs.mensys>
</prs.mensys>
</prs>
</spr.cams>
</spr>
</sce.srs>
<sce.srs>
<sce_scjc.sce.srs>150052468/1</sce_scjc.sce.srs>
<sce_seq2.sce.srs>01</sce_seq2.sce.srs>
<sce_stuc.sce.srs>150052468</sce_stuc.sce.srs>
<spr>
<spr.cams>
<spr_code.spr.cams>150052468/1</spr_code.spr.cams>
<prs_code.spr.cams/>
</spr.cams>
</spr>
</sce.srs>
</sce>
</exchange>
And my XSL looks like the passaage below. I have a nil element template that I added in as I thought looking for a value was easier than looking for a nulll so happy for it to come out if not needed.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/exchange/sce">
<ImportTask>
<EntityRelationshipEntities>
<xsl:apply-templates select="node()|#*"/>
</EntityRelationshipEntities>
</ImportTask>
</xsl:template>
<xsl:template name="nilElement">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="string($value)">
<xsl:value-of select="$value"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="xsi:nil" namespace="http://www.w3.org/2001/XMLSchema-instance">True</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sce.srs[not(*/AttributeValue[not(#AttributeValue='True')])]">
<xsl:for-each select="spr/spr.cams">
<EntityRelationshipEntity>
<ErRef>ERREF_21</ErRef>
<EntityCode><xsl:value-of select="../../sce_stuc.sce.srs"/></EntityCode>
<AttributeValue>
<xsl:call-template name="nilElement">
<xsl:with-param name="value" select="prs/prs.mensys/prs_name.prs.mensys"/>
</xsl:call-template>
</AttributeValue>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
</xsl:for-each>
</xsl:template>
<xsl:template match="AttributeValue[#AttributeValue = 'True']"/>
</xsl:stylesheet>
So this currently gives me:
<ImportTask xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EntityRelationshipEntities>
<EntityRelationshipEntity>
<ErRef>ERREF_21</ErRef>
<EntityCode>151514490</EntityCode>
<AttributeValue xsi:nil="True"/>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
<EntityRelationshipEntity>
<ErRef>ERREF_21</ErRef>
<EntityCode>140008305</EntityCode>
<AttributeValue>Johan</AttributeValue>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
<EntityRelationshipEntity>
<EntityCode>151516736</EntityCode>
<AttributeValue>Evangelia</AttributeValue>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
</EntityRelationshipEntities>
</ImportTask>
What I would like to produce is out those where is not null. This would mean that the child below is not output:
<EntityRelationshipEntity>
<ErRef>ERREF_21</ErRef>
<EntityCode>151514490</EntityCode>
<AttributeValue xsi:nil="True"/>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
But the others would be output something like this:
<ImportTask xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EntityRelationshipEntities>
<EntityRelationshipEntity>
<ErRef>ERREF_21</ErRef>
<EntityCode>140008305</EntityCode>
<AttributeValue>Johan</AttributeValue>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
<EntityRelationshipEntity>
<EntityCode>151516736</EntityCode>
<AttributeValue>Evangelia</AttributeValue>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
</EntityRelationshipEntities>
</ImportTask>
Can someone help me apply this correctly?
Many thanks
Jonah
Perhaps I am missing something, but couldn't this be simply:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/exchange/sce">
<ImportTask xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EntityRelationshipEntities>
<xsl:apply-templates select="sce.srs/spr/spr.cams[string(prs/prs.mensys/prs_name.prs.mensys)]"/>
</EntityRelationshipEntities>
</ImportTask>
</xsl:template>
<xsl:template match="spr.cams">
<EntityRelationshipEntity>
<ErRef>ERREF_21</ErRef>
<EntityCode>
<xsl:value-of select="../../sce_stuc.sce.srs"/>
</EntityCode>
<AttributeValue>
<xsl:value-of select="prs/prs.mensys/prs_name.prs.mensys"/>
</AttributeValue>
<Action>VALUEONLY</Action>
</EntityRelationshipEntity>
</xsl:template>
</xsl:stylesheet>