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 5947169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:55:35+00:00 2026-05-22T16:55:35+00:00

I am having the following XML: <?xml version=1.0?> <abc:Element1 xmlns:abc=http://…./resources/abc/v2/ …> <abc:Element2> <abc:Element3s> <abc:Element4

  • 0

I am having the following XML:

<?xml version="1.0"?>
    <abc:Element1 xmlns:abc="http://..../resources/abc/v2/"
         ...>
         <abc:Element2>
            <abc:Element3s>
                 <abc:Element4 name="name1"
                               resourceRef="name2"/>
            </abc:Element3s>
         </abc:Element2>

         <abc:Resources>
            <abc:Resource xsi:type="abc:Something"
                          name="name2"/>
         </abc:Resources>
     </abc:Element1>   

… and this XSLT stylesheet:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:abc="http://.../resources/abc/v2/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <xsl:template match="/">
     <checker name="something">
       <xsl:for-each select="abc:Element1/abc:Element2/abc:Element3s/abc:Element4">
        <xsl:variable name="resource" select="@resourceRef"/>
        <xsl:variable name="xsiType"><xsl:value-of select="//abc:Resource[@name=$resource]/@xsi:type"/></xsl:variable>
        <xsl:choose>
            <xsl:when test="$xsiType='abc:Something'">
               ...
            </xsl:when>
            <xsl:otherwise>
               ...
            </xsl:otherwise>
         </xsl:choose>
       </xsl:for-each>
     </checker>
   </xsl:template>
</xsl:stylesheet>

I am using XALAN 2.7.1 with org.apache.xalan.xsltc.trax.TransformerFactoryImpl (also tried with org.apache.xalan.processor.TransformerFactoryImpl -> same result) to transform the XML.

I expect the following line to store abc:Something in variable xsiType.

<xsl:variable name="xsiType"><xsl:value-of select="//abc:Resource[@name=$resource]/@xsi:type"/></xsl:variable>

but unfortunatley only Something (without namespace as prefix) is stored in xsiType. I verified this because

<xsl:when test="$xsiType='abc:Something'">

is not true.

I also transformed the XMl using xsltproc and the resulting XML looks as expected. Therefore, I expect the input XML/XSLT stylesheet to be correct. I assume something is wrong with Xalan and its configuration.

Can anyone help?

  • 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-22T16:55:36+00:00Added an answer on May 22, 2026 at 4:55 pm

    Your sample data is not well-formed, so it’s difficult to tell. This is likely to be a namespace issues. Here’s a sanitized version of your input and stylesheet that extracts the data you want:

    <?xml version="1.0"?>
    <abc:Element1
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:abc="http://resources/abc/v2">
        <abc:Element2>
            <abc:Element3s>
                <abc:Element4 name="name1" resourceRef="name2"/>
            </abc:Element3s>
        </abc:Element2>
        <abc:Resources>
            <abc:Resource xsi:type="abc:Something" name="name2"/>
        </abc:Resources>
    </abc:Element1>
    
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:abc="http://resources/abc/v2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        exclude-result-prefixes="abc xsi"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <xsl:variable name="resource" select="'name2'"/>
            <xsl:variable name="type"
                select="//abc:Resource[@name=$resource]/@xsi:type"/>
            <checker name="{ $type }"/>
        </xsl:template>
    </xsl:stylesheet>
    

    This will produce:

    <?xml version="1.0"?>
    <checker name="abc:Something"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML similar to the following <?xml version=1.0 encoding=utf-8?> <foo name=FooBar xmlns=http://mydomain/myapp/ver/myschema.xsd> <bars
I am having xml with following structure <ruleDefinition appId=3 customerId = acf> <node alias=element1
having the following XML sample document, I need to issue an XPath/XQuery expression to
I'm having the following issue - I want to traverse all the xml files
Hi currently I have a nested XMl , having the following Structure : <?xml
I am having XML like as follows <Components> <Component> <Name>Comp1</Name> <Baseline>Comp1_2.1.0.20.2824</Baseline> <KLOC>0</KLOC> <IsCount>True</IsCount> </Component>
help me please i'm having the following issue: I'm trying to read a XML
I am having trouble finding why the following XML won't deserialize. Message: There is
I have a input file Main.xml <?xml version=1.0 encoding=utf-8 ?> <Employees> <Employee> <id name=id>1</id>
I have to generate the following xml in my program using JAXB. <?xml version=1.0

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.