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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:38:06+00:00 2026-06-14T09:38:06+00:00

I have the following XML: <types> <type> <name>derived</name> <superType>base</superType> <properties> <property> <name>B1</name> </property> <property>

  • 0

I have the following XML:

<types>
    <type>
        <name>derived</name>
        <superType>base</superType>
        <properties>
            <property>
                <name>B1</name>
            </property>
            <property>
                <name>D1</name>
            </property>
        </properties>
    </type>
    <type>
        <name>base</name>
        <properties>
            <property>
                <name>B1</name>
            </property>
        </properties>
    </type>
</types>

Which I want to tranform to this output:

derived
    D1

base
    B1

Note that node /types/type[name='derived']/properties/property[name='B1'] has been skipped since it exists in the base type as: /types/type[name='base']/properties/property[name='B1'].

I have come up with this XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" omit-xml-declaration="yes"/>
    <xsl:strip-space elements="*"/>

    <!-- Do nothing for base class properties -->
    <!-- Wouldn't be necessary if the match criteria could be applied in the select -->
    <xsl:template match="property"/>

    <xsl:template match="property[not(//type[name=current()/../../superType]/properties/property[name=current()/name])]">
        <xsl:text>&#x09;</xsl:text>
        <xsl:value-of select="name"/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

    <xsl:template match="types/type">
        <xsl:value-of select="name"/>
        <xsl:text>&#10;</xsl:text>
        <xsl:apply-templates select="./properties"/>
        <xsl:text>&#10;</xsl:text>
    </xsl:template>

</xsl:stylesheet>

This works (using the XML Tools plug-in in Notepad++), but the not(//type[name=current()/../../superType]/properties/property[name=current()/name]) XPath expression is horribly inefficient: when applied to a 200K line XML file, the transform takes 280 seconds. Without this XPath expression the transform only takes 2 seconds.

Is there some way to speed this up?

  • 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-06-14T09:38:07+00:00Added an answer on June 14, 2026 at 9:38 am

    Measure this for speed…

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" encoding="utf-8"/>
    <xsl:strip-space elements="*"/>
    
    <xsl:key name="kPropertyByName" match="property" use="name" /> 
    
    <xsl:template match="property">
      <xsl:variable name="supertype" select="../../superType/text()" />
      <xsl:if test="($supertype = '') or not ( key('kPropertyByName',name)/../../name[.=$supertype])">
        <xsl:value-of select="concat('&#x09;',name,'&#x0A;')" /> 
      </xsl:if>  
    </xsl:template>  
    
    <xsl:template match="type">
      <xsl:value-of select="concat(name,'&#x0A;')" />
      <xsl:apply-templates select="properties" />
      <xsl:text>&#x0A;</xsl:text>
    </xsl:template>  
    
    </xsl:stylesheet>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xml types: <xsd:element name=FaxNumbers minOccurs=0> <xsd:complexType> <xsd:sequence> <xsd:element name=FaxNumber type=FaxNumber
I have the following XML: <projects> <project> <name>Super 1</name> <types> <type>Art</type> <type>Retro</type> </types> </project>
I have following xml and I want to fetch the value of node which
I have the following XML (simplification): <?xml version=1.0 encoding=utf-8?> <TestCases> <TestCase> <Name>Test1</Name> <Result>Failed</Result> <Properties>
I have following XML: <Library> <Item> <Field Name=Name>smooth</Field> <Field Name=File Type>mid</Field> <Field Name=File Size>60026</Field>
I have the following xml <root> <document> <account>12</account> <type name-a>stuff</type> <type name-b>stuff</type> </document> <document>
I have the following XML document named testFix.fix <WriteFixedWidth Type=extract> <Position Start=1 Length=15 Name=Field1
I have the following XML doc: <files> <elements xsi:type=foo:elementType1> <name>foo1</name> </elements> <elements xsi:type=foo:elementType1> <name>foo2</name>
i have following XML <Queue> <UserName>UserName</UserName> <Type>1</Type> <Portal name=Portal1> <IndexesForSelect> <Index>Index1</Index> <Index>Index2</Index> </IndexesForSelect> </Portal>
I have the following jQuery $.ajax({ type: GET, url: http://f.cl.ly/items/0i1V1L1k2F440L1m2Y0G/pointdata.xml, dataType: xml, success: parseXml

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.