0

I have XML with product's parameters like colors.

<parameter name='color'>
   <value>black</value>
   <value>white</value>
</parameter>

I want to output a value like so:

<g:color>black/white</g:color>

Important is that number or values isn't known. Mostly it is 1 value but can be also 2 or more sometimes.

I did a for-each loop selecting all value nodes so for the moment I have result like:

<g:color>blackwhite</g:color>

So without separator. When I try to use <xsl:text>/</xsl:text> I got an error. Probably I have to escape it or wrap it somehow but I don't know the solution.

2
  • 1
    Please post your current XSLT so we can fix it instead of having to write your code for you from scratch. Commented Nov 15, 2024 at 11:06
  • 1
    While asking an XSLT question you need to provide a minimal reproducible example: (1) Well-formed input XML with all relevant namespaces. (2) Your logic, and complete executable XSLT stylesheet that tries to implement it. (3) Desired output, based on the sample XML in the #1 above. (4) XSLT processor and its conformance with the XSLT standards: 1.0, 2.0, 3.0, or 4.0. Commented Nov 15, 2024 at 14:58

1 Answer 1

0

Try adding:

<xsl:if test="position()!=last()">/</xsl:if>

inside your xsl:for-each instruction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.