Page 1 of 1

text to xml

Posted: Tue Jul 08, 2014 9:30 am
by Le Basque
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

Re: text to xml

Posted: Wed Jul 09, 2014 2:18 pm
by Le Basque
I am the only one with this problem? :(

Re: text to xml

Posted: Wed Jul 09, 2014 2:25 pm
by adrian
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

Re: text to xml

Posted: Wed Jul 09, 2014 2:26 pm
by Le Basque
Thank you