text to xml

Here should go questions about transforming XML with XSLT and FOP.
Le Basque
Posts: 147

text to xml

Tue Jul 08, 2014 9:30 am

Hi,

I have text file contains information :

Code: Select all

The design of the Darwin Information Typing Architecture (DITA)
This specification describes specific details of each element in the OASIS DITA language.
The elements that make up the DITA design represent a set of different authoring concerns

I use xml file :

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<document/>

I use file xsl in V2

Code: Select all

<xsl:stylesheet version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:fo="http://www.w3.org/1999/XSL/Format"
   xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output encoding="UTF-8" indent="yes"/>
<xsl:template match="document">
    <xsl:variable name="inputText"
                  select="unparsed-text(resolve-uri('input.txt',base-uri(/)),'UTF-8')"/>
    <xsl:copy>
        <xsl:analyze-string select="$inputText" regex="\n">
            <xsl:non-matching-substring>
                <p><xsl:value-of select="."/></p>
            </xsl:non-matching-substring>
        </xsl:analyze-string>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>

I obtains in result :

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<document>
   <p xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">The design of the Darwin Information Typing Architecture (DITA)</p>
   <p xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">This specification describes specific details of each element in the OASIS DITA language.</p>
   <p xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">The elements that make up the DITA design represent a set of different authoring concerns</p>
</document>

My question : how do to remove information xmlns:xs="http://www.w3.org/2001/XMLSchema" and xmlns:fo="http://www.w3.org/1999/XSL/Format" in file result

Thank you for help
Le Basque
Posts: 147

Re: text to xml

Wed Jul 09, 2014 2:18 pm

I am the only one with this problem? :(
adrian
Posts: 2451

Re: text to xml

Wed Jul 09, 2014 2:25 pm

Hi,

You have to explicitly mention the namespace prefixes that should be excluded from the output.
Add this attribute to the xsl:stylesheet root element:

Code: Select all

exclude-result-prefixes="xs fo"

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Le Basque
Posts: 147

Re: text to xml

Wed Jul 09, 2014 2:26 pm

Thank you

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 2 guests