0

Pretty new to XSLT 2.0.

I have a snippet of code from a text file:

INSERT˝ITEM˝0180528˝ITEM˝304854˝˝STANDARD˝˝Towncar ˝061˝612˝123˝025˝Y˝0040928˝˝4000.95˝0˝0˝4000.95˝EA˝
INSERT˝CAR_STYLE˝18206˝COLOR˝Red
INSERT˝CAR_STYLE˝18206˝ENGINE˝V6

I want to generate an XML that produces:

<color>
    <colorId>Red</colorId>
    <description>Red</description>
<color>

I am trying to use XSLT 2.0 to parse through the text file to gather this information and create the xml. I will have to create multiple xslt files to parse the text, so getting a look at a simple example will help.

1
  • 1
    How do you intend to point the XSL transformation to the text file? Once you have that, it should be easy to use regex to extract any part. Commented Jun 19, 2017 at 19:55

1 Answer 1

2

It's not very clear how your input relates to the output, or what the actual structure/grammar of the input is. However the general approach is:

  • Use the unparsed-text() function to read the input file

  • Use tokenize() to split it into a sequence of lines.

  • Use xsl:analyze-string to break up each line into its parts

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

1 Comment

Those steps helped a lot. Thanks!

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.