Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4122720
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:31:05+00:00 2026-05-20T23:31:05+00:00

i was trying to figure out what is wrong with this piece of code,

  • 0

i was trying to figure out what is wrong with this piece of code, but, after 4 hours, I give up! I tried a lot of different solutions here on stackoverflow and from arround the web, bot none of them worked.

All i’m trying to do, is to put “gml:coordinates” value to the “point” attribute. I guess it has something to do with the namespace. Or something else…

XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<gml:LineString>
    <gml:coordinates>-7 -7 0 7 -7 0 7 7 0 -7 7 0</gml:coordinates>
</gml:LineString>

XSL file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:gml="http://www.opengis.net/gml">

<xsl:template match="/gml:LineString">
    <Transform>
        <Shape>
            <IndexedFaceSet>
                <xsl:attribute name="coordIndex">
                    <xsl:text>0 1 2 3 -1</xsl:text>
                </xsl:attribute>

                <Coordinate>
                    <xsl:attribute name="point">
                        <xsl:text>
                            <xsl:value-of select="/gml:coordinates" />
                        </xsl:text>
                    </xsl:attribute>
                </Coordinate>
            </IndexedFaceSet>
        </Shape>
    </Transform>
</xsl:template>
</xsl:stylesheet> 

And the Ajax script (returns correct results if attribute is set to “-7 -7 0 7 -7 0 7 7 0 -7 7 0” insted of “/gml:coordinates”):

var xml = document.implementation.createDocument("", "", null);
var xsl = document.implementation.createDocument("", "", null);
xml.async = false;
xsl.async = false;
xml.load("xsl/ajax.xml");
xsl.load("xsl/ajax.xsl");
var processor = new XSLTProcessor();
processor.importStylesheet(xsl);
var output = processor.transformToFragment(xml, document);
document.getElementById("scene").appendChild(output);

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:31:06+00:00Added an answer on May 20, 2026 at 11:31 pm

    Just replace:

    <Coordinate>
      <xsl:attribute name="point">
        <xsl:text>
          <xsl:value-of select="/gml:coordinates" />
        </xsl:text>
      </xsl:attribute>
    </Coordinate>
    

    with:

    <Coordinate>
      <xsl:attribute name="point">
          <xsl:value-of select="gml:coordinates" />
      </xsl:attribute>
    </Coordinate>
    

    Explanation: There are at least two problems here:

    1. <xsl:text> cannot contain other xsl elements inside itself — only text.

    2. The XPath expression /gml:coordinates selects nothing, because there is no /gml:coordinates top element in the source XML document.

    Further refactoring: The code can be further simplified by using *AVT*s (attribute-value templates):

    Replace:

    <Coordinate>
      <xsl:attribute name="point">
          <xsl:value-of select="gml:coordinates" />
      </xsl:attribute>
    </Coordinate>
    

    with:

    <Coordinate point="{gml:coordinates}"/>
    

    Replace:

    <IndexedFaceSet>
      <xsl:attribute name="coordIndex">
        <xsl:text>0 1 2 3 -1</xsl:text>
      </xsl:attribute>
    

    with:

    <IndexedFaceSet coordIndex="0 1 2 3 -1">
    

    The complete code after the corrections and refactorings:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:gml="http://www.opengis.net/gml">
        <xsl:template match="/gml:LineString">
            <Transform>
                <Shape>
                    <IndexedFaceSet coordIndex="0 1 2 3 -1">
                        <Coordinate point="{gml:coordinates}"/>
                    </IndexedFaceSet>
                </Shape>
            </Transform>
        </xsl:template>
    </xsl:stylesheet>
    

    and the result is:

    <Transform xmlns:gml="http://www.opengis.net/gml">
        <Shape>
            <IndexedFaceSet coordIndex="0 1 2 3 -1">
                <Coordinate point="-7 -7 0 7 -7 0 7 7 0 -7 7 0"/>
            </IndexedFaceSet>
        </Shape>
    </Transform>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to figure out what is wrong in this code. it either doesn't
I spend a lot of time trying to figure out what's wrong with this
I am trying to figure out what is wrong with this code, I need
spent a few hours trying to figure this out, but cannot for the life
Trying to figure out this pseudo code. The following is assumed.... I can only
So I'm trying to figure out what I'm doing wrong with this logic. It
I've been trying to figure this out all evening but to no avail. I
I am trying to figure out how to make this snip of code work:
I'm trying to figure out what I'm doing wrong here, but I can't seem
I have already lost 2 days trying to figure out on this issue, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.