text to xml

Here should go questions about transforming XML with XSLT and FOP.
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

text to xml

Post 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
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: text to xml

Post by Le Basque »

I am the only one with this problem? :(
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: text to xml

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: text to xml

Post by Le Basque »

Thank you
Post Reply