472,338 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

java works, but xmlspy seems broken and some xsd and space questions?

hi, trying to convert some csv files into xsml and pulling a few hairs
out :(. using the files below. a java program will parse the csv and
take care of strange names and notes that line breaks in them.

eventiually i want to generate the xslt from a xml file (all the files
and java code are at http://tayek.com/~ray/spy1/).

the java code (1.4) does the right thing (it just does the
transformation). xmlspy seems really broken when i hit f10 to run the
inputDocument.xml through the sampleT1.xslt (i am trying the enterprize
version). even putting in <xsl:text> </xsl:text>", the spy just
seems to ignore it (but the java does something reasonable).

also, i have text in my xslt like <outputRow> and later </outputRow>.
this is one of the things what xmlspy seems to discard.

the field names from the csv (called inputFieldName in the xml) can
contain some screwball stuff line ' and ", so i made these text
elements an xs:string. they can not contain any other xml (i.e. no
<...>). so is xs:string the right way to do this? or should one use
normalized string?

what does nillable mean or do? - it lets things be empty? is there a way
to force things to have just attributes and no content?

there should be *no* text or any other markup (ignoring specal for the
moment) anywhere except for inside an inputField or an inputFieldName.
is there a way to tell the schema thia?

eventually, i want to use the a file like inputDocumentMap.xml to
generate the xslt using xslt (i am doing this now in java, but with a
different inputDocumentMap.xml file).

any pointers would be appreciated.

thanks
file inputDocument.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 (http://www.xmlspy.com) by Ray
Tayek (Freightgate) -->
<!--Sample XML file generated by XMLSPY v2004 rel. 3 U
(http://www.xmlspy.com)-->
<inputDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="H:\java\projects\sp y1\spy\inputDocument.xsd">
<special>Text</special>
<header>
<inputFieldName>copy1</inputFieldName>
<inputFieldName>remove1</inputFieldName>
<inputFieldName>rename1</inputFieldName>
<inputFieldName>special1</inputFieldName>
<inputFieldName>special2</inputFieldName>
</header>
<inputRecords>
<inputRecord>
<inputField>copy1Value1</inputField>
<inputField>remove1Value1</inputField>
<inputField>rename1Value1</inputField>
<inputField>special1Value1</inputField>
<inputField>special2Value1</inputField>
</inputRecord>
<inputRecord>
<inputField>copy1Value2</inputField>
<inputField>remove1Value2</inputField>
<inputField>rename1Value2</inputField>
<inputField>special1Value2</inputField>
<inputField>special2Value2</inputField>
</inputRecord>
</inputRecords>
</inputDocument>

file inputDocument.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Ray
Tayek (Freightgate) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="inputDocument">
<xs:annotation>
<xs:documentation>input csv converted to xml</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="special" type="xs:anyType" minOccurs="0"/>
<xs:element name="header" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="inputFieldName" type="xs:string"
nillable="false" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="inputRecords" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="inputRecord" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="inputField" type="xs:string"
nillable="false" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
files sampleT.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<?xmlspysamplexml inputDocument.xml?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--<xsl:strip-space elements="*"/>-->
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/inputDocument">
<outputDocument>
<xsl:apply-templates/>
</outputDocument>
</xsl:template>
<xsl:template match="/inputDocument/special">
</xsl:template>
<xsl:template match="/inputDocument/header">
</xsl:template>
<xsl:template match="/inputDocument/inputRecords">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/inputDocument/inputRecords/inputRecord">
<!--<xsl:for-each select="child::*[position()=4 or position()=5]">
works -->
<xsl:for-each select="child::*">
<xsl:if test="position()=4">
<xsl:call-template name="generateOutputRecord">
<xsl:with-param name="value1" select="'new1ValueFromSpecial1Name'"/>
<xsl:with-param name="value2" select="'new2ValueFromSpecial1Name'"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="position()=5">
<xsl:call-template name="generateOutputRecord">
<xsl:with-param name="value1" select="'new1ValueFromSpecial2Name'"/>
<xsl:with-param name="value2" select="'new2ValueFromSpecial2Name'"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="generateOutputRecord">
<xsl:param name="value1" select="defaultValue1"/>
<xsl:param name="value2" select="defaultValue2"/>
<outputRow>
<inputRecordSequenceNumber>
<xsl:number count="inputRecord"/>
</inputRecordSequenceNumber>
<xsl:for-each select="../*">
<xsl:call-template name="processField"/>
</xsl:for-each>
<xsl:call-template name="addNewFields">
<xsl:with-param name="xvalue1" select="$value1"/>
<xsl:with-param name="xvalue2" select="$value2"/>
</xsl:call-template>
</outputRow>
</xsl:template>
<xsl:template name="addNewFields">
<xsl:param name="xvalue1" select="defaultValue1"/>
<xsl:param name="xvalue2" select="defaultValue2"/>
<xsl:element name="new1">
<xsl:value-of select="$xvalue1"/>
</xsl:element>
<xsl:element name="new2">
<xsl:value-of select="$xvalue2"/>
</xsl:element>
<xsl:element name="new3">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template name="processField">
<xsl:choose>
<xsl:when test="position()=4"/>
<xsl:when test="position()=5"/>
<xsl:when test="position()=2"/>
<xsl:when test="position()=3">
<xsl:element name="renamed1">
<xsl:value-of select="."/>
</xsl:element>
</xsl:when>
<xsl:when test="position()=1">
<xsl:element name="{/inputDocument/header/inputFieldName[1]}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
-->
</xsl:stylesheet>

output from spy:

1 copy1Value1 rename1Value1 new1ValueFromSpecial1Name
new2ValueFromSpecial1Name special1Value1 1 copy1Value1 rename1Value1
new1ValueFromSpecial2Name new2ValueFromSpecial2Name special2Value1 2
copy1Value2 rename1Value2 new1ValueFromSpecial1Name
new2ValueFromSpecial1Name special1Value2 2 copy1Value2 rename1Value2
new1ValueFromSpecial2Name new2ValueFromSpecial2Name special2Value2

output from java program: file outputDocument_.xml:

<?xml version="1.0" encoding="UTF-8"?>
<outputDocument>
<outputRow>
<inputRecordSequenceNumber>1</inputRecordSequenceNumber>
<copy1>copy1Value1</copy1>
<renamed1>rename1Value1</renamed1>
<new1>new1ValueFromSpecial1Name</new1>
<new2>new2ValueFromSpecial1Name</new2>
<new3>special1Value1</new3>
</outputRow>
<outputRow>
<inputRecordSequenceNumber>1</inputRecordSequenceNumber>
<copy1>copy1Value1</copy1>
<renamed1>rename1Value1</renamed1>
<new1>new1ValueFromSpecial2Name</new1>
<new2>new2ValueFromSpecial2Name</new2>
<new3>special2Value1</new3>
</outputRow>
<outputRow>
<inputRecordSequenceNumber>2</inputRecordSequenceNumber>
<copy1>copy1Value2</copy1>
<renamed1>rename1Value2</renamed1>
<new1>new1ValueFromSpecial1Name</new1>
<new2>new2ValueFromSpecial1Name</new2>
<new3>special1Value2</new3>
</outputRow>
<outputRow>
<inputRecordSequenceNumber>2</inputRecordSequenceNumber>
<copy1>copy1Value2</copy1>
<renamed1>rename1Value2</renamed1>
<new1>new1ValueFromSpecial2Name</new1>
<new2>new2ValueFromSpecial2Name</new2>
<new3>special2Value2</new3>
</outputRow>
</outputDocument>

inputDocumentMap.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 (http://www.xmlspy.com) by Ray
Tayek (Freightgate) -->
<!--Sample XML file generated by XMLSPY v2004 rel. 3 U
(http://www.xmlspy.com)-->
<inputDocumentMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="H:\java\projects\sp y1\spy\inputDocumentMap.xsd">
<inputFieldMap>
<inputFieldname>copy1</inputFieldname>
<map>
<from>oldValue1</from>
<to>newValue1</to>
</map>
<map>
<from>oldValue2</from>
<to>newValue2</to>
</map>
</inputFieldMap>
<inputFieldMap delete="true">
<inputFieldname>remove1</inputFieldname>
</inputFieldMap>
<inputFieldMap>
<inputFieldname outputFieldName="renamed1">rename1</inputFieldname>
</inputFieldMap>
<inputFieldMap delete="true">
<inputFieldname>special1</inputFieldname>
<generate outputFieldName="new1">new1ValueFromSpecial1Name</generate>
<generate outputFieldName="new2">new2ValueFromSpecial1Name</generate>
<generate outputFieldName="new3" copyOriginalValue="true">will be
ignored</generate>
</inputFieldMap>
<inputFieldMap delete="true">
<inputFieldname>special2</inputFieldname>
<generate outputFieldName="new1">new1ValueFromSpecial2Name</generate>
<generate outputFieldName="new2">new2ValueFromSpecial2Name</generate>
<generate outputFieldName="new3" copyOriginalValue="true">will be
ignored</generate>
</inputFieldMap>
</inputDocumentMap>
inputDocumetMap.xsd file:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Ray
Tayek (Freightgate) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="inputDocumentMap">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="inputFieldMap" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="inputFieldname" nillable="false">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="outputFieldName" type="xs:Name"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="map" nillable="false" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="from" type="xs:string" nillable="false"/>
<xs:element name="to" type="xs:string" nillable="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="generate" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="outputFieldName" type="xs:string"
use="required"/>
<xs:attribute name="copyOriginalValue" type="xs:boolean"
use="optional" default="false"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="delete" type="xs:boolean" use="optional"
default="false"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Jul 20 '05 #1
0 2037

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lars | last post by:
Hi all, I suspect this may be a bug in XMLSpy, since IE seems to validate this XML successfully. Maybe someone here has run into this and can tell...
2
by: Patrick J. Maloney | last post by:
I received a file from a business partner. I ran it through XercesJ and it choked on the following element: <wcb-case-number>0</wcb-case-number>...
8
by: Beatrice Rutger | last post by:
Hi, I am a previous Micro$oft desertee (moved from VB/VC++ to Java before this whole DOTNET thing) because I had several issues with Micro$oft. I...
235
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This...
6
by: quanghoc | last post by:
Hi all, I used XMLSpy to validate my XML but it catched one error at a time. Is there anyway to make XMLSpy to catch all errors at once. If XMLSpy...
318
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.