IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: RobertB
About
User Name: RobertB
Forum Rank: Member
Real Name:
Location Denver
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Saturday, March 23, 2013
Last Visit: Wednesday, June 11, 2014 3:10:35 PM
Number of Posts: 12
[0.07% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: XSLT1 adding line feeds
Posted: Tuesday, June 10, 2014 11:14:09 PM
Hi,

I am nearing completion of a project but I need to be able to add a line feed. I know xslt users have it easy with code_to_string but I cannot use XSLT2 for this project so I am limited in doing it the hard way.

I want to join multiple strings together, but I need to add a line feed into one of the Concat values.

I searched the forum, but the closest answer I could get is generating a custom library.

This is some of the code I came up with but it seems to be giving me errors:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:fn="http://www.w3.org/2005/xpath-functions"
   xmlns:msxsl="urn:schemas-microsoft-com:xslt"
   xmlns:user="http://mycompany.com/mynamespace">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template name="char-from-code">
<xsl:param name="value" />
<xsl:value-of select="fn:codepoints-to-string(xs:integer(xs:decimal($value)))"/>
</xsl:template>
</xsl:stylesheet>



Error I am getting :

Code:

    XSLT Transformation failed: Error in XPath expression (Unknown function - Name and number of arguments do not match any function signature in the static context - 'http://www.w3.org/2005/xpath-functions:codepoints-to-string' - fn:codepoints-to-string)
Error occurred in file 'C:\Users\Librairies\Char_From_Code.xslt' in statement 'select="fn:codepoints-to-string(xs:integer(xs:decimal($value)))"'.


Any idea on what I am missing to make this work? Seems it does not recognize "codepoints-to-string" function even when adding the xpath function xmlns:fn="http://www.w3.org/2005/xpath-functions"

Many thanks!

Robert
Topic: ESRI Recordset translation with Mapforce
Posted: Wednesday, May 15, 2013 1:47:35 AM
Anyone has any input or trick that could be used?

Thanks
Topic: ESRI Recordset translation with Mapforce
Posted: Thursday, May 9, 2013 11:37:39 PM
Hi gents,

Having a bit of an issue trying to map an xml recordset in Mapforce.

I was provided an xml recordset from ESRI arcmap and have been asked to translate it to our in house XSD. Normally I have no problem dealing with xml translations, but this specific xml is not very common.

Here is a sample of the structure I have to deal with :

Code:
<Data xsi:type="esri:RecordSet">
<Fields xsi:type="esri:Fields">
<FieldArray xsi:type="esri:ArrayOfField">
<Field xsi:type="esri:Field">
<Name>OBJECTID</Name>
<Type>esriFieldTypeOID</Type>
<IsNullable>false</IsNullable>
</Field>
<Field xsi:type="esri:Field">
<Name>TRACT_ID</Name>
<Type>esriFieldTypeDouble</Type>
<IsNullable>true</IsNullable>
</Field>
<Field xsi:type="esri:Field">
<Name>POPULATION</Name>
<Type>esriFieldTypeDouble</Type>
<IsNullable>true</IsNullable>
</Field>
</FieldArray>
</Fields>
<Records xsi:type="esri:ArrayOfRecord">
<Record xsi:type="esri:Record">
<Values xsi:type="esri:ArrayOfValue">
<Value xsi:type="xs:int">1</Value>
<Value xsi:type="xs:double">100</Value>
<Value xsi:type="xs:double">4231</Value>
</Values>
</Record>
<Record xsi:type="esri:Record">
<Values xsi:type="esri:ArrayOfValue">
<Value xsi:type="xs:int">2</Value>


Here is a link on the ESRI documentation : http://downloads.esri.com/support/whitepapers/ao_/J9620_XML_Schema_of_Geodatabase.pdf

So in few words, this xml consists of a header defining the various fields used and then the data is orderd in the same way the fields were introduced. Is there any way to translate this type of xml with mapforce or any tool I need to parse this type of file with before starting a good ole translation and create an xslt from this?

Any help would be much appreciated, I am at wits end!!

Thank you

Topic: Value Map in XSLT 1
Posted: Wednesday, March 27, 2013 11:54:13 PM
Thanks for the tip Vlad!! That worked, was able to insert all my references using that trick!

Thank again!!!
Topic: Value Map in XSLT 1
Posted: Wednesday, March 27, 2013 4:13:28 AM
Is there a way in map force to build a value map from external files? I have over 2000 entries on a look up tables, there must be a better way than hand entering each one of them manually?

Any tip is appreciated, thanks!
Topic: Mapforce - Flatten a node and all its rows (XSLT1 only)
Posted: Sunday, March 24, 2013 9:04:52 AM
vlad wrote:
No idea about your code, but I hope you do know that you can use MapForce for database import too, i.e. you might want to completely avoid this one library which limits you to XSLT1.


Thanks for the response Vlad. I wish I sincerely could. I am just part of that project and we are working with legacy applications... I have numerous times requested for support for XSLT2 support but its not going to happen. You see we have some serious software on the back end managing numerous automated xslt translation so its not as simple as an import.

I will keep looking, might be more complicated but no other way. Thanks again for the help!

RB
Topic: Mapforce - Flatten a node and all its rows (XSLT1 only)
Posted: Sunday, March 24, 2013 5:52:57 AM
I have been testing the the above template... I was never able to grab any data from the fields...

I have been using this template:

Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
  <xsl:output method="text" indent="yes"/>
  <!-- join integer array by separator ',' -->
  <xsl:template match="/incidents/incident/IncidentResponse/ActivityDescriptionText">
    <xsl:value-of select="local-name()"/>
    <xsl:text>: </xsl:text>
    <xsl:call-template name="join">
      <xsl:with-param name="valueList" select="*"/>
      <xsl:with-param name="separator" select="','"/>
    </xsl:call-template>
    <xsl:text>&#xa;&#xd;</xsl:text>
  </xsl:template>
  <!-- join children elements by separator ' | ' -->
  <xsl:template match="/incidents/incident/IncidentResponse/ActivityDescriptionText">
    <xsl:value-of select="local-name()"/>
    <xsl:text>: </xsl:text>
    <xsl:call-template name="join">
      <xsl:with-param name="valueList" select="*"/>
      <xsl:with-param name="separator" select="' | '"/>
    </xsl:call-template>
    <xsl:text>&#xa;&#xd;</xsl:text>
  </xsl:template>
  <!-- template 'join' accepts valueList and separator -->
  <xsl:template name="join" >
    <xsl:param name="valueList" select="''"/>
    <xsl:param name="separator" select="','"/>
    <xsl:for-each select="$valueList">
      <xsl:choose>
        <xsl:when test="position() = 1">
          <xsl:value-of select="."/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="concat($separator, .) "/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>


I edited this line :

<xsl:template match="/incidents/incident/IncidentResponse/ActivityDescriptionText">

To match the location of the node I want to flatten, however it is getting everything in between the host node and the data I want


ex:


<IncidentResponse><----- Pointing to this node
<name> </name>
<Address></Address>
<id></id>
<ActivityDescriptionText> </ActivityDescriptionText> <------Node I want to flatten
</IncidentResponse>

However the template is flattening every node in between and concatenating every field. What I'm I doing wrong?

Any help is appreciated,

Thank you!!!




Topic: Mapforce - Flatten a node and all its rows (XSLT1 only)
Posted: Sunday, March 24, 2013 2:49:22 AM
Have been researching different ways of how to add String-Join to XSLT1, it seems there is a way to add libraries to Mapforce. Any library packages that could do what I need for mapforce.

Any tips would be much appreciated.

Thanks!

Update :


Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="*">
        <xsl:for-each select=".">
            <xsl:call-template name="join">
                <xsl:with-param name="context" select="."/>
            </xsl:call-template>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="join">
        <xsl:param name="context"/>
        <xsl:for-each select="$context/ITEM">
            <xsl:value-of select="concat(ITEM_TEXT,' ')"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>


Seems using the above template could work by adding it as a library and then using the function to concatenate the field. Will test.

Please let me know if anyone has any other ideas.

Thanks
Topic: Mapforce - Flatten a node and all its rows (XSLT1 only)
Posted: Saturday, March 23, 2013 4:07:11 PM
vlad wrote:
You need string-join function, which is only available for XSLT2. There is no reason to stick to XSLT1 six years after XSLT2 introduction.


I figured as much, but I have no choice really. Our dev team is limited to xslt1 due to restrictions on the xml database importer code and a Library we are using. So pretty much stuck, any workaround?
Topic: Mapforce - Flatten a node and all its rows (XSLT1 only)
Posted: Saturday, March 23, 2013 1:50:07 PM
Hi,

I am working on a project that only supports XSLT1. Here is the issue:

I am trying to translate an xml to a specific xsd format.

I have 1 node that contains multiple Rows and I need to concatenate all the values to one output.



Code:
Ex:
                                                                         
Xml input nod (NameTxtDefined) w multiple rows                                                         Output XML
<name>Roger</name>
<name>Linda</name>
<name>John</name>                                  ------>                          <name>Roger, Linda, John, Richard, Mark</name>
<name>Richard</name>
<name>Mark</name>

I use a specific key to allow multiple entries but for a specific key I often get this results in the output

<name>Roger</name>
<name>Linda</name>
<name>John</name>                                 
<name>Richard</name>
<name>Mark</name>



Any way to flatten the rows into a single string on XSLT1?


Any help is much appreciated!

Thank,

Robert

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.