|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how can this be done in XML???
Hi,
i need clarification regarding the following: 1) is it possible to embed a text file(eg: data.txt) as tags in XML? eg; <area>D:\mydocuments\data.txt</area> 2) if yes, is it possible to extract data values from a single column in the text file and display it using XSL? thanks in advance. also, I want the users' form selections to be written back as xml when the html form is submitted. Is there a way to do this? |
|
#2
|
||||
|
||||
|
1. I believe that whatever is contructing your XML will need to read in the file and that add the text from the file to the element as text data. Make sure that all special XML characters are propertly taken care of when you do this. What language are you using to construct your XML?
2. If when you say column, you mean character n from every line, this can be done. I can write a template that takes character N from every line that is seperated by a newline. Quote:
Yes, depending on what language you are using on the server ... you can set the response mime type to "text/xml" and just feed the XML document through whatever object that represents your response. |
|
#3
|
||||
|
||||
|
I am writing the template now.
|
|
#4
|
||||
|
||||
|
This is an XSL template that can be used to extract a column from a text file:
Code:
<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:call-template name="getColumn"> <xsl:with-param name="content" select="rootNode"/> <xsl:with-param name="columnNumber" select="6"/> </xsl:call-template> </xsl:template> <xsl:template name="getColumn"> <xsl:param name="content"/> <xsl:param name="columnNumber" select="1"/> <xsl:variable name="LINE_SEPERATOR" select="' '"/> <xsl:if test="string-length($content) > 0"> <xsl:value-of select="substring($content, $columnNumber, 1)"/> <xsl:call-template name="getColumn"> <xsl:with-param name="content" select="substring-after($content, $LINE_SEPERATOR)"/> <xsl:with-param name="columnNumber" select="$columnNumber"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> Test XML: Code:
<?xml version="1.0"?> <rootNode>Line 1 Line 2 Line 3 Line 4 Line 5</rootNode> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > how can this be done in XML??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|